IRONSOFTWAREHOME
How to Merge PDF Files in C#
using IronPdf;

var html_a = @"<p> [PDF_A] </p>
        <p> [PDF_A] 1st Page </p>
        <div style = 'page-break-after: always;' ></div>
        <p> [PDF_A] 2nd Page</p>";

var html_b = @"<p> [PDF_B] </p>
        <p> [PDF_B] 1st Page </p>
        <div style = 'page-break-after: always;' ></div>
        <p> [PDF_B] 2nd Page</p>";

var renderer = new ChromePdfRenderer();

var pdfdoc_a = renderer.RenderHtmlAsPdf(html_a);
var pdfdoc_b = renderer.RenderHtmlAsPdf(html_b);
var merged = PdfDocument.Merge(pdfdoc_a, pdfdoc_b);

merged.SaveAs("Merged.pdf");
Imports IronPdf

Dim html_a = "<p> [PDF_A] </p>
        <p> [PDF_A] 1st Page </p>
        <div style = 'page-break-after: always;' ></div>
        <p> [PDF_A] 2nd Page</p>"

Dim html_b = "<p> [PDF_B] </p>
        <p> [PDF_B] 1st Page </p>
        <div style = 'page-break-after: always;' ></div>
        <p> [PDF_B] 2nd Page</p>"

Dim renderer = New ChromePdfRenderer()

Dim pdfdoc_a = renderer.RenderHtmlAsPdf(html_a)
Dim pdfdoc_b = renderer.RenderHtmlAsPdf(html_b)
Dim merged = PdfDocument.Merge(pdfdoc_a, pdfdoc_b)

merged.SaveAs("Merged.pdf")
NuGet Download
PM > Install-Package IronPdf
How to Merge PDF Files in C#

How to Merge PDF Files in C#

IronPDF's merge feature allows you to combine multiple PDF documents into a single file seamlessly. Whether you're working with HTML-rendered PDFs or existing PDF files, IronPDF provides a simple API for merging. Leverage IronPDF's powerful merge features to effortlessly combine your PDFs while maintaining the structure and content integrity of each document.

The 5 Steps to Merging PDF Documents in C#

Before we can begin merging our PDF documents, we first need to create the HTML string that will be used to render the PDF documents in this example. These HTML strings are named html_a and html_b. Once these have been created, we can move on to rendering and merging the PDFs.

First, you will need to create a new ChromePdfRenderer instance. This powerful renderer will be used to convert the HTML content we created to high-quality PDF documents. By using the RenderHtmlAsPdf method, we can then render the HTML content into PDF documents.

Now, it is time to merge the PDF documents into a single PDF named Merged.pdf. This is done through the Merge method, which takes the two PDF documents passed to it and merges them using just one line of code. This makes merging documents an efficient and easy-to-implement task with IronPDF.

Finally, all that is left to do is save the merged PDF. From here, you can utilize IronPDF's various PDF tools to further edit and manipulate this PDF document.

Beyond the basic merging of two PDF documents, IronPDF is capable of merging any number of PDF documents. In our basic example, we demonstrated how you would merge two PDF documents by specifying both PDFs as separate arguments. To merge more than two documents, you would need to replace this two-argument method with a List overload, as seen here in a more advanced code example:

Learn to Merge PDFs with Easy Code Examples
View on GitHub

Ready to Get Started?

Nuget Downloads 20,878,335Version:2026.9just released

Key in blue circle

Get your free 30-day Trial Key instantly.

Your trial license will be sent to your email address

No limitations. 100% unlocked. No credit card.

bullet_checkedNo credit card or account creation requiredNo limitations. 100% unlocked. No credit card.
  • Logo Aetna
  • Logo NASA
  • Logo GE
  • Logo Porsche
  • Logo USDA
  • Logo Qatar
Join Millions of Engineers who’ve tried IronPDF
Book your free Live Demo
Booking Badge

Trusted by Millions of Engineers Worldwide

Iron Software's customer logos
Get Your No-Obligation Consult
Complete the form below or email sales@ironsoftware.com
Your details will always be kept confidential.
Trusted by Millions of Engineers Worldwide
Iron Software's customer logos
Get your free 30-day Trial Key instantly.
No credit card or account creation required