Merge Two or More PDFs
Merge PDFs of all sizes and complexity with ease and confidence with IronPDF's Merge
method.
The PdfDocument.Merge
method joins two or more PDFs together into a single PDF document.
Use the PdfDocument.Merge
method in your C# projects to:
- Add cover pages or cover letters to existing PDFs programmatically,
- Merge PDFs converted from HTML documents
PdfDocument.Merge
can merge any number of PDFs together.
How to Merge PDF Files in Python
- Download the PDF library to merge PDF files in Python.
- Create a New Python Project in PyCharm or any other IDE.
- Load or Create two or more PDF files using
RenderHtmlAsPdf
method. - Merge The PDF files using
PdfDocument.Merge
method. - Save the new PDF file using
SaveAs
Method.
More Details
To merge two PDF documents, specify both PDFs as separate arguments, as shown in line 17 of the featured example.
To merge more than two PDF files, substitute the two-argument method with its List
overload:
List<PdfDocument> pdfs = new List<PdfDocument>()
{
pdfdoc_a,
pdfdoc_b,
pdfdoc_c,
// ...
};
var merged = PdfDocument.Merge(pdfs);
merged = SaveAs("Merged.pdf");
List<PdfDocument> pdfs = new List<PdfDocument>()
{
pdfdoc_a,
pdfdoc_b,
pdfdoc_c,
// ...
};
var merged = PdfDocument.Merge(pdfs);
merged = SaveAs("Merged.pdf");
Dim pdfs As New List(Of PdfDocument)() From {pdfdoc_a, pdfdoc_b, pdfdoc_c}
Dim merged = PdfDocument.Merge(pdfs)
merged = SaveAs("Merged.pdf")