Joining Two or More PDFs

IronPDF for Python can combine multiple PDF documents into a single file using the PdfDocument.Merge method, making it straightforward to assemble multi-part documents from separate sources.

Getting Started

Create or load two or more PdfDocument objects, then pass them to PdfDocument.Merge. The method returns a new PdfDocument containing all pages from the input documents in the order they were provided.

Understanding the Code

  • ChromePdfRenderer: Used here to render two HTML strings into separate PdfDocument objects. You can also load existing PDFs with PdfDocument.FromFile.
  • RenderHtmlAsPdf(html): Converts an HTML string into a PdfDocument. Each rendered document becomes one section of the final merged PDF.
  • PdfDocument.Merge(pdfdoc_a, pdfdoc_b): Combines two PdfDocument objects into a single document. The pages from pdfdoc_a appear first, followed by the pages from pdfdoc_b.
  • SaveAs("Merged.pdf"): Saves the merged document to the specified file path.

Merging More Than Two Documents

To merge more than two documents at once, pass a list of PdfDocument objects to PdfDocument.Merge:

merged = PdfDocument.Merge([doc_a, doc_b, doc_c])
merged = PdfDocument.Merge([doc_a, doc_b, doc_c])
PYTHON

Learn to merge and split 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.