IRONSOFTWAREHOME
Add Classic Text Headers & Footers
from ironpdf import *

# Initiate PDF Renderer
renderer = ChromePdfRenderer()

# Add a header to every page easily
renderer.RenderingOptions.FirstPageNumber = 1  # use 2 if a cover page will be appended
renderer.RenderingOptions.TextHeader.DrawDividerLine = True
renderer.RenderingOptions.TextHeader.CenterText = "{url}"
renderer.RenderingOptions.TextHeader.Font = FontTypes.Helvetica
renderer.RenderingOptions.TextHeader.FontSize = 12
renderer.RenderingOptions.MarginTop = 25  # create 25mm space for header

# Add a footer too
renderer.RenderingOptions.TextFooter.DrawDividerLine = True
renderer.RenderingOptions.TextFooter.Font = FontTypes.Arial
renderer.RenderingOptions.TextFooter.FontSize = 10
renderer.RenderingOptions.TextFooter.LeftText = "{date} {time}"
renderer.RenderingOptions.TextFooter.RightText = "{page} of {total-pages}"
renderer.RenderingOptions.MarginBottom = 25  # create 25mm space for footer

# Mergeable fields are:
# {page} {total-pages} {url} {date} {time} {html-title} & {pdf-title}
NuGet Download
Install-Package ironpdf
Add Classic Text Headers & Footers

Add Classic Text Headers & Footers

IronPDF for Python makes it easy to add consistent text-based headers and footers to every page of a rendered PDF using the TextHeader and TextFooter properties of RenderingOptions.

Getting Started

Configure TextHeader and TextFooter on a ChromePdfRenderer instance before rendering. Set MarginTop and MarginBottom to create enough space so the headers and footers do not overlap the page content.

Understanding the Code

  • TextHeader: A TextHeaderFooter object that configures the header appearing at the top of every page.
  • TextFooter: A TextHeaderFooter object that configures the footer appearing at the bottom of every page.
  • DrawDividerLine: When True, draws a horizontal line separating the header or footer from the page body.
  • CenterText: The text displayed in the center position. Supports dynamic merge fields.
  • LeftText / RightText: Text aligned to the left and right of the header or footer area.
  • Font / FontSize: Controls the typeface and size of the header/footer text.
  • MarginTop / MarginBottom: Page margins in millimeters. Increase these to reserve space for headers and footers.
  • FirstPageNumber: The starting page number. Set to 2 when a cover page will be prepended to the document.

Dynamic Merge Fields

The following tokens are replaced with live values at render time:

{page} {total-pages} {url} {date} {time} {html-title} {pdf-title}

Learn to add headers and footers to PDFs with IronPDF for Python!

Ready to Get Started?

Version:2026.8just released

Key in blue circle

Get your free 30-day Trial Key instantly.

No limitations. 100% unlocked. No credit card.

bullet_checkedNo credit card or account creation requiredNo limitations. 100% unlocked. No credit card.
  • Logo Aetna
  • Logo NASA
  • Logo GE
  • Logo Porsche
  • Logo USDA
  • Logo Qatar
Join Millions of Engineers who’ve tried IronPDF
Book your free Live Demo
Booking Badge

Trusted by Millions of Engineers Worldwide

Iron Software's customer logos
Get Your No-Obligation Consult
Complete the form below or email sales@ironsoftware.com
Your details will always be kept confidential.
Trusted by Millions of Engineers Worldwide
Iron Software's customer logos
Get your free 30-day Trial Key instantly.
No credit card or account creation required