Remove headers and footers from a Word DOCX document in C# .NET Framework

Cloudmersive
2 min readFeb 7, 2020

--

While generally a pretty handy feature, sometimes you really just need your headers and footers to take a hike. Whether it’s for the sake of compatibility, web display, or printing, the process is the same. And today, that process is going to be simplified enormously, as you are about to see.

Right off the bat, we need to install our API client. This can be done easily enough with NuGet — simply run this command in your console of Package Manager.

Install-Package Cloudmersive.APIClient.NET.DocumentAndDataConvert -Version 2.2.0

Ok, next we shall call the function that we need, EditDocumentDocxRemoveHeadersAndFooters. Here is the code needed for that.

using System;using System.Diagnostics;using Cloudmersive.APIClient.NET.DocumentAndDataConvert.Api;using Cloudmersive.APIClient.NET.DocumentAndDataConvert.Client;using Cloudmersive.APIClient.NET.DocumentAndDataConvert.Model;namespace Example{public class EditDocumentDocxRemoveHeadersAndFootersExample{public void main(){// Configure API key authorization: ApikeyConfiguration.Default.AddApiKey("Apikey", "YOUR_API_KEY");// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed// Configuration.Default.AddApiKeyPrefix("Apikey", "Bearer");var apiInstance = new EditDocumentApi();var reqConfig = new RemoveDocxHeadersAndFootersRequest(); // RemoveDocxHeadersAndFootersRequest | Document input requesttry{// Remove headers and footers from Word DOCX documentRemoveDocxHeadersAndFootersResponse result = apiInstance.EditDocumentDocxRemoveHeadersAndFooters(reqConfig);Debug.WriteLine(result);}catch (Exception e){Debug.Print("Exception when calling EditDocumentApi.EditDocumentDocxRemoveHeadersAndFooters: " + e.Message );}}}}

Our document is now free from all headers and footers. Easy, right?

--

--

Cloudmersive
Cloudmersive

Written by Cloudmersive

There’s an API for that. Cloudmersive is a leader in Highly Scalable Cloud APIs.

No responses yet