Get Started
Usage API
More information

RemoveHeader

RemoveHeader(sType)

Remove the header of the specified type from the current section. After removal the header will be inherited from the previous section or, if this is the first section in the document, no header of the specified type will be present.

Parameters:

Name Type Description
sType HdrFtrType

Header type to be removed.

Returns:

This method doesn't return any data.

Example

Copy code
builder.CreateFile("docx");
oDocument = Api.GetDocument();
oParagraph = oDocument.GetElement(0);
oParagraph.AddText("This page first was with a header. ");
oParagraph.AddText("The header has been removed, you cannot see it. ");
oParagraph.AddText("Scroll down to the next page to see the header there.");
oSection = oDocument.CreateSection(oParagraph);
oHeader = oSection.GetHeader("default", true);
oParagraph = oHeader.GetElement(0);
oParagraph.AddText("This is page header #1. ");
oParagraph.AddText("You will not see it, as it will be removed.");
oParagraph = Api.CreateParagraph();
oParagraph.AddText("This is a page with a header. ");
oDocument.Push(oParagraph);
oSection1 = oDocument.GetFinalSection();
oHeader = oSection1.GetHeader("default", true);
oParagraph = oHeader.GetElement(0);
oParagraph.AddText("This is page header #2. ");
oParagraph.AddText("Only this header can be seen, as the first one has been removed.");
oSection.RemoveHeader("default");
builder.SaveFile("docx", "RemoveHeader.docx");
builder.CloseFile();

Resulting document