Merge Multiple PDFs with a Cover Page

IronPDF for Python provides a concise set of methods for combining, restructuring, and extracting pages from PDF documents — merging multiple files, prepending cover pages, removing pages, and copying page subsets in just a few lines of code.

Getting Started

Load existing PDFs into a typed List[PdfDocument] collection and pass it to PdfDocument.Merge to combine them. From there, use PrependPdf, RemovePage, and CopyPages to further shape the document before saving.

Understanding the Code

  • List[PdfDocument](): A typed .NET-style list used to collect multiple PdfDocument objects before merging. Call .Add() to append each document.
  • PdfDocument.FromFile(path): Opens an existing PDF file and returns it as a PdfDocument object.
  • PdfDocument.Merge(pdfs): Combines all documents in the list into a single PdfDocument, preserving page order.
  • SaveAs(path): Writes the current state of the document to disk.
  • PrependPdf(pdf): Inserts another PdfDocument at the very beginning of the current document — used here to add a rendered HTML cover page as the first page.
  • RemovePage(index): Removes a single page at the specified zero-based index. pdf.PageCount - 1 targets the last page.
  • CopyPages(ToPageList([4, 6])): Extracts specific pages by their zero-based indexes and returns them as a new PdfDocument. ToPageList converts a Python list of indexes into the required page list format.
  • eachPdf.Dispose(): Releases the underlying resources held by each loaded PdfDocument after the merge is complete.

Zero-Based Page Indexing

All page operations in IronPDF use zero-based indexes. Page 5 of a document is at index 4, page 7 is at index 6, and so on.

Learn to merge and edit PDFs with IronPDF for Python!

Ready to Get Started?
Version: 2026.6 just released
Still Scrolling Icon

Still Scrolling?

Want proof fast?
run a sample watch your HTML become a PDF.