Examples

Merge PDF

In the following three examples, you merge PDF documents. The first example illustrates merging two documents in a single step, the second appending three documents in three steps, and the third adding output options that suppress included bookmarks in a merged PDF.

Watch the Video

How to Merge PDF

The following steps illustrates merging PDF documents and adding options when merging a document.

Steps for Merging a PDF Document

  1. Create a MergeDocument object using the static Merge method, passing the 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");

Steps to Append PDF

Append multiple PDFs by calling the Append method. The following steps and sample code illustrates.

  1. Create a MergeDocument object and pass the first document to the constructor.
  2. Call the MergeDocument instance's Append method and pass the PDF to be merged. Repeat for all documents requiring merging.
  3. Call the Document instance's Draw method to save the appended document.

Sample Code - C#

MergeDocument document = new MergeDocument("DocumentA.pdf");
document.Append("DocumentB.pdf");
document.Append("DocumentC.pdf");
document.Draw("output.pdf");

Steps for Specifying MergeOptions for a PDF Document

You can specify different options while appending a document using the MergeOptions class, the following sample code illustrates.

  1. Create a MergeDocument object and pass the first document to its constructor.
  2. Create a MergeOptions object by calling the Append static property.
  3. Set the MergeOptions Outlines method to false.
  4. Pass the MergeOptions object to the Append method.
  5. Call the MergeDocument Append method, passing in an additional PDF to be merged.
  6. Call the Draw method to save the appended document.

This example is admittedly simplified. In this example you specify that Outlines does not import a PDF's outlines or bookmarks. Other examples include FormsXfaData, OutputIntent, and other possible options. For more information, refer to the MergeOptions class referenced above.

Sample Code - C#

MergeDocument document = new MergeDocument("DocumentA.pdf");
MergeOptions options = MergeOptions.Append;
options.Outlines = false;
document.Append("DocumentB.pdf", options);
document.Append("DocumentC.pdf");
document.Draw("output.pdf") ;

GitHub Project

Clone or view the example project at GitHub. This example code above is in the Examples/MergePDFs.cs file.

Clone or View Example Project on GitHub

Getting Started

NuGet Package

DynamicPDF Core Suite is available on NuGet and is part of the ceTe.DynamicPDF.CoreSuite.NET package. The easiest way to install the package is through the Visual Studio Package Manager, but you can also download from NuGet.

NuGet Package ID: ceTe.DynamicPDF.CoreSuite.NET

DynamicPDF Core Suite Information

More information on DynamicPDF Core Suite is available from its website.

Available on Other Platforms

DynamicPDF Core Suite is also available for Java and COM/ActiveX. Refer to the respective product pages for more details.

Why Choose DynamicPDF?

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

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