Get Started
Documentation

GetHeader

GetHeader(sType, isCreateopt) → (nullable) {ApiDocumentContent}

Get the content for the specified header type.

Parameters:

Name Type Attributes Default Description
sType HdrFtrType Type of header to get the content from.
isCreate boolean <optional> false Whether to create a new header or not with the specified header type in case no header with such a type could be found in the current section.

Returns:

Type
ApiDocumentContent

Example

Copy code
builder.CreateFile("docx");
var oDocument = Api.GetDocument();
var oParagraph, oHeader;
oParagraph = oDocument.GetElement(0);
oParagraph.AddText("This is a page with a header. ");
oParagraph.AddText("See it above.");
var oSection = oDocument.GetFinalSection();
oHeader = oSection.GetHeader("default", true);
oParagraph = oHeader.GetElement(0);
oParagraph.AddText("This is a page header");
builder.SaveFile("docx", "GetHeader.docx");
builder.CloseFile();

Resulting document