HTML Headers & Footers

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

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


// Build a footer using html to style the text
// mergable fields are:
// {page} {total-pages} {url} {date} {time} {html-title} & {pdf-title}
Renderer.PrintOptions.Footer = new HtmlHeaderFooter()
{
  Height = 15,
  HtmlFragment = "<center><i>{page} of {total-pages}<i></center>",
  DrawDividerLine = true
 };

// Build a header using an image asset
// Note the use of BaseUrl to set a relative path to the assets
Renderer.PrintOptions.Header = new HtmlHeaderFooter()
{
  Height = 20,
  HtmlFragment = "<img src='logo.png'>",
  BaseUrl = new Uri(@"C:\assets\images\").AbsoluteUri
};
Imports IronPdf

Private Renderer As New IronPdf.HtmlToPdf()


' Build a footer using html to style the text
' mergable fields are:
' {page} {total-pages} {url} {date} {time} {html-title} & {pdf-title}
Renderer.PrintOptions.Footer = New HtmlHeaderFooter() With {
	.Height = 15,
	.HtmlFragment = "<center><i>{page} of {total-pages}<i></center>",
	.DrawDividerLine = True
}

' Build a header using an image asset
' Note the use of BaseUrl to set a relative path to the assets
Renderer.PrintOptions.Header = New HtmlHeaderFooter() With {
	.Height = 20,
	.HtmlFragment = "<img src='logo.png'>",
	.BaseUrl = (New Uri("C:\assets\images\")).AbsoluteUri
}

HTML Headers and Footers are rendered as independent HTML documents which may have their own assets and stylesheets. Developers may control the Height of the rendered Header or Footer to match their content exactly.