IronPDF for Python makes it straightforward to prepend a custom cover page to any PDF document, creating professionally structured reports and documents.
Getting Started
Render two separate PDFs - one for the cover and one for the main content - then merge them into a single document using PdfDocument.Merge. Set FirstPageNumber = 2 on the main content renderer so that page numbers begin at 2, accounting for the cover page.
Understanding the Code
renderer.RenderHtmlAsPdf(html): Renders the cover page HTML as a standalonePdfDocument.FirstPageNumber = 2: Tells IronPDF that the first page of the main content should be numbered 2. This is important when a footer or header includes{page}merge fields.renderer.RenderUrlAsPdf(url): Renders the main document content from a URL.PdfDocument.Merge(cover, pdf): Combines the cover page PDF with the main document PDF, placing the cover first. Returns a new mergedPdfDocument.SaveAs("combined.pdf"): Saves the merged document to disk.
Customizing the Cover Page
The cover page HTML can include any content - company logo, document title, author, date, and formatting. Use the same ChromePdfRenderer with its full range of rendering options (fonts, margins, backgrounds) to style the cover page.