Merge PDF in C# (.NET Core)

Merge, combine PDFs in C#, .NET, .NET Core or Standard

DynamicPDF makes Merging PDFs together easy. Here are some examples on the basic steps and how to specify what data is merged by using merge options.

How to Merge PDF Files

Below are the steps and sample code to merge PDF files with and without options.

Steps to Merge PDFs

  1. Create a MergeDocument object using the static Merge method, passing in two PDFs to be merged.
  2. Call the Draw method to save the merged PDF.

Sample code - C#

MergeDocument document = MergeDocument.Merge("DocumentA.pdf", "DocumentB.pdf");
document.Draw("output.pdf");

If you have additional PDFs to merge, you can append them by calling the Append method.

Sample code with Append - C#

MergeDocument document = new MergeDocument();

document.Append("doc-a.pdf");
document.Append("doc-b.pdf");
document.Append("doc-c.pdf");

document.Draw("output.pdf");

Specifying The Type of Content to Be Merged

  1. If you would like to specify differant options, you can do so by creating the MergeOptions object.
  2. Modify the options as per requirement. In the example, the Outlines is set to false.
  3. Pass the MergeOptions object into the Append method.

Sample code for MergeOptions - C#

MergeOptions options = MergeOptions.Append;
options.Outlines = false;

document.Append("DocumentC.pdf, options);

Getting Started

NuGet Package

DynamicPDF Merger is available on NuGet and is part of the ceTe.DynamicPDF.CoreSuite.NET package. The Core Suite package includes Generator, Merger and ReportWriter.

Nuget Logo
NuGet Package ID: ceTe.DynamicPDF.CoreSuite.NET

Example Project

An example project showing this functionality can be cloned or viewed from GitHub:

GitHub Logo
Clone or View Example Project on GitHub

DynamicPDF Merger Information

More information can be found here:

Available in Other Platforms

DynamicPDF Merger PDF Library is available for Java and COM/AxtiveX platforms. Refer to the respective product pages for more details.

Why Choose DynamicPDF?

  • Lots of Features
  • Easy to Use
  • Great Support
  • Efficient Performance
  • Product Maturity (Over 17 Years)
  • Free Evaluation
  • .NET Core Support (Most Products)
  • Flexible Licensing

We’re Not The Only Ones That Think We’re Great!