Add HTML Headers & Footers

IronPDF allows the developer to modify PDF documents to use customized headers and footers. This code example shows how developers can achieve this using the ChromeRenderOptions class along with the HtmlHeaderFooter class.

The HtmlHeaderFooter class allows the developer to customize a PDF's header or footer using HTML, as opposed to just using plain text (as is the case with the TextHeaderFooter class). Specify the HTML markup for the header or footer by calling the addHtmlFragment method on an instance of the class. This method accepts a String containing valid HTML5, CSS3, and JavaScript (ECMAScript 6). IronPDF will interpret the content in this string as rich hypertext markup, displaying it in resulting PDF documents in the same manner that a web browser would.

The developer can use this class to create headers that incorporate images, colors, special typefaces, and other, more complex design elements.

For more traditional and simplified text-based header/footer customizations, consider opting for the TextHeaderFooter class instead.