Combine PDF documents
In the following example you combine three PDF documents into a single PDF.
Watch the Video
How to Combine PDF Documents
The following steps illustrate combining multiple PDF documents into a single PDF.
Steps for Combining PDF Documents
- Create a
MergeDocument
object by passing the first PDF file to the constructor. - Call the
Append
method with the second PDF document. - Call the
Append
method a third time to append another PDF document. Also pass the1
, and2
page parameters to theAppend
method. - Call the
Draw
method to save the merged PDF.
The Append
method has several overloaded methods, including specifying the start page and page count properties. For example, the Append
method below appends two pages of the document DocumentC.pdf, beginning with page one. For more information on the options available to you using Append
, refer to the MergeDoccument.Append documentation.
Sample Code - C#
MergeDocument document = new MergeDocument("DocumentA.pdf");
document.Append("DocumentB.pdf);
document.Append("DocumentC.pdf, 1, 2);
document.Draw("Output.pdf");
Steps for Specifying MergeOptions for PDF Document
- Create a
MergeOptions
object by calling the staticAppend
method. - Set the
MergeOptions
Outlines
tofalse
. - Create a new
MergeDocument
. - Call the
Append
method to append a document. Also passoptions
to theAppend
method. - Call the
Draw
method to save the merged PDF.
As mentioned above, the Append
method has several overloaded methods available for you to use. In this example, you use the MergeOptions
class combined with the Outlines
property to specify that the PDF's outlines and bookmarks are not imported. Refer to the MergeOptions documentation for more information.
Sample Code - C#
MergeOptions options = MergeOptions.Append;
options.Outlines = false;
MergeDocument document = new MergeDocument();
document.Append("DocumentC.pdf", options);
document.Draw("Output.pdf");
GitHub Project
Clone or view the example project at GitHub. The example code is in the Examples/CombinePDFs.cs file.
Getting Started
NuGet Package
The easiest way to install the DynamicPDF Core Suite NuGet package is by installing it directly using the Visual Studio Package Manager. But the DynamicPDF Core Suite NuGet ceTe.DynamicPDF.CoreSuite.NET
package is also available directly from NuGet.
DynamicPDF Core Suite Information
More information on DynamicPDF Core Suite can be found at the DynamicPDF Core Suite webpage.
- [DynamicPDF Core Suite for .NET](https://www.dynamicpdf.com/docs/dotnet/dynamic-pdf-core-suite-welcome"Merge, Combine, Join Split PDFs programmatically")
Available on Other Platforms
The DynamicPDF Core Suite is also available for Java and COM/ActiveX. Refer to the respective product pages for more details.
- Java - DynamicPDF Merger for Java
- COM/ActiveX - DynamicPDF Merger for COM/ActiveX