Headers & Footers

C# + VB.Net: Headers & Footers Headers & Footers
using IronPdf;

IronPdf.HtmlToPdf Renderer = new IronPdf.HtmlToPdf();

// add a header to every page easily
Renderer.PrintOptions.FirstPageNumber = 1; // use 2 if a coverpage  will be appended
Renderer.PrintOptions.Header.DrawDividerLine = true;
Renderer.PrintOptions.Header.CenterText = "{url}" ;
Renderer.PrintOptions.Header.FontFamily = "Helvetica,Arial";
Renderer.PrintOptions.Header.FontSize = 12;

// add a footer too
Renderer.PrintOptions.Footer.DrawDividerLine = true;
Renderer.PrintOptions.Footer.FontFamily = "Arial";
Renderer.PrintOptions.Footer.FontSize = 10;
Renderer.PrintOptions.Footer.LeftText = "{date} {time}";
Renderer.PrintOptions.Footer.RightText = "{page} of {total-pages}";

// mergable fields are:
// {page} {total-pages} {url} {date} {time} {html-title} & {pdf-title}
Imports IronPdf

Private Renderer As New IronPdf.HtmlToPdf()

' add a header to every page easily
Renderer.PrintOptions.FirstPageNumber = 1 ' use 2 if a coverpage  will be appended
Renderer.PrintOptions.Header.DrawDividerLine = True
Renderer.PrintOptions.Header.CenterText = "{url}"
Renderer.PrintOptions.Header.FontFamily = "Helvetica,Arial"
Renderer.PrintOptions.Header.FontSize = 12

' add a footer too
Renderer.PrintOptions.Footer.DrawDividerLine = True
Renderer.PrintOptions.Footer.FontFamily = "Arial"
Renderer.PrintOptions.Footer.FontSize = 10
Renderer.PrintOptions.Footer.LeftText = "{date} {time}"
Renderer.PrintOptions.Footer.RightText = "{page} of {total-pages}"

' mergable fields are:
' {page} {total-pages} {url} {date} {time} {html-title} & {pdf-title}

Headers and Footers may be added to PDF documents in 2 distinct ways.
- SimpleHeaderFooter allows text based headers to be added, with the option to merge in dynamic data.
- HtmlHeaderFooter allows the developer to render HTML headers and footers to PDF files, also allowing the templating of dynamic data.