Sections
Headers and Footers
Creating Headers and Footers
Headers and footers are defined in a Section. Multiple headers and footers can be defined in each section to specify different scopes. The scope refers to which pages the header or footer will be added to in the section.
Header Scopes
| Method | Description |
|---|---|
HeaderFirstPage() | This header will be added to the first page the section |
HeaderEvenPages() | This header will be only added to even pages in the section |
Header() | When used by itself, this header will be added to all pages. If used with either HeaderFirstPage() or HeaderEvenPages(), this header will be added to all pages except the first and even pages, respectively. |
Footer Scopes
| Method | Description |
|---|---|
FooterFirstPage() | This footer will be added to the first page the section |
FooterEvenPages() | This footer will be only added to even pages in the section |
Footer() | When used by itself, this footer will be added to all pages. If used with either FooterFirstPage() or FooterEvenPages(), this footer will be added to all pages except the first and even pages, respectively. |
WordDocument.Create(filePath, document =>
{
document.Section(section =>
{
// This header will be applied to the first page of the section.
section.HeaderFirstPage(header =>
{
header.Paragraph("FluentWriter")
.AlignLeft()
.Bold()
.FontSize(18);
});
// This header will be applied to all other pages.
section.Header(header =>
{
header.Paragraph("www.fluentwriter.net")
.Center();
});
section.Content(content =>
{
content.Paragraph("This is a simple paragraph.");
});
// This footer will be applied to all pages of the section.
section.Footer(footer =>
{
footer.Paragraph("FluentWriter");
footer.Paragraph("www.fluentwriter.net");
});
});
});