HeaderFooterType

HeaderFooterType enumeration

Identifies the type of header or footer found in a Word file.

public enum HeaderFooterType

Values

NameValueDescription
HeaderEven0Header for even numbered pages.
HeaderPrimary1Primary header, also used for odd numbered pages.
FooterEven2Footer for even numbered pages.
FooterPrimary3Primary footer, also used for odd numbered pages.
HeaderFirst4Header for the first page of the section.
FooterFirst5Footer for the first page of the section.

Examples

Shows how to create headers and footers in a document using DocumentBuilder.

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

// Specify that we want different headers and footers for first, even and odd pages.
builder.PageSetup.DifferentFirstPageHeaderFooter = true;
builder.PageSetup.OddAndEvenPagesHeaderFooter = true;

// Create the headers, then add three pages to the document to display each header type.
builder.MoveToHeaderFooter(HeaderFooterType.HeaderFirst);
builder.Write("Header for the first page");
builder.MoveToHeaderFooter(HeaderFooterType.HeaderEven);
builder.Write("Header for even pages");
builder.MoveToHeaderFooter(HeaderFooterType.HeaderPrimary);
builder.Write("Header for all other pages");

builder.MoveToSection(0);
builder.Writeln("Page1");
builder.InsertBreak(BreakType.PageBreak);
builder.Writeln("Page2");
builder.InsertBreak(BreakType.PageBreak);
builder.Writeln("Page3");

doc.Save(ArtifactsDir + "DocumentBuilder.HeadersAndFooters.docx");

See Also