Merging PDFs
Easily merge multiple PDF documents when using DynamicPDF Core Suite for .NET. Refine the output from merging by specifying merge options. The following C# examples show you how.
Watch the Video
How to Merge PDF
The following steps and C# example code illustrates merging PDF documents and adding options when merging a document.
Steps for Merging a PDF Document
- Create a
MergeDocumentobject using the staticMergemethod, passing the two PDFs to be merged. - Add the
Drawmethod 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 C# sample code illustrates.
- Create a
MergeDocumentobject and pass the first document to the constructor. - Add the
MergeDocumentinstance'sAppendmethod and pass the PDF to be merged. Repeat for all documents requiring merging. - Add the Document instance's
Drawmethod 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
You can specify different options while appending a document using the MergeOptions class, the following sample code illustrates.
- Create a
MergeDocumentobject and pass the first document to its constructor. - Create a
MergeOptionsobject by calling theAppendstatic property. - Set the
MergeOptionsOutlines method tofalse. - Pass the
MergeOptionsobject to theAppendmethod. - Add the
MergeDocumentAppendmethod, passing in an additional PDF to be merged. - Add the
Drawmethod to save the appended document.
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
Examples are provided in C# and VB.NET. Clone or view the example project at GitHub. This example code above is in the following files.
- C# - MergePdfExample.cs
- VB.NET - MergePdfExample.vb
Getting Started
Get started easily by installing DynamicPDF Core Suite for .NET through NuGet or manually. Then, refer to the documentation for more information on using and purchasing the product.
NuGet Package
The easiest way to install DynamicPDF Core Suite is by obtaining the NuGet package using Visual Studio's Package Manager. You can also obtain the NuGet package by downloading it directly. Refer to the installation documentation for more information.
DynamicPDF Core Suite Information
DynamicPDF Core Suite for .NET combines creating, merging, and visual report creation into one powerful product for creating PDF documents. It is ideal for anyone who needs to generate PDF documents or reports or work with existing PDFs in their applications. With a free Evaluation Edition to try and with flexible and royalty-free licensing options, why not start using DynamicPDF Core Suite for .NET today!
More Information on Combining PDFs
- Refer to the Merging Overview documentation topic, or
- Chapter 22, Merging, in the book DynamicPDF Core Suite for .NET by Example available on GitHub.
Available on Other Platforms
DynamicPDF Core Suite is also available for the Java and COM/ActiveX platforms. Refer to the respective product pages for more details.
- DynamicPDF Generator
- Java - DynamicPDF Generator for Java
- COM/ActiveX - DynamicPDF Generator for COM/ActiveX
- DynamicPDF Merger
- Java - DynamicPDF Merger for Java
- COM/ActiveX - DynamicPDF Merger for COM/ActiveX