Cookbook

Generate different headers and footers for multiple sections

If you need to create headers and footers dynamically for multiple sections, you must use an Advanced or Premium license.

There are two approaches to accomplish this task:

To illustrate both possibilities, let's prepare a cover page with no headers or footers in the first page, and then a second page with only a footer and the rest of the pages filled with both headers and footers using sections.

Using addHeaderSection and addFooterSetion methods

This is the easiest approach to generate different headers and footers for sections:

Using MultiMerge features

This approach creates a document for each combination of headers and footers and then merges them all in a single DOCX instead of generating a single document with different types of headers and footers:

Premium licenses allow doing all these steps using in-memory DOCX to get the best performace.