Merge Two or More PDFs in C#

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:

  1. Add cover pages or cover letters to existing PDFs programmatically,
  2. Merge PDFs converted from HTML documents

PdfDocument.Merge can merge any number of PDFs together.



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")
VB   C#