PDF merge library v10.0.0

PDF Merge for .NET

ExpertPdf MergePDF is a royalty free .NET library that combines existing PDF documents and images into a single PDF document. You can integrate it into your C#, VB.NET or ASP.NET application in a few minutes.

Set the page size, orientation and compression level, the title, author and creation date, and protect the merged document with a password and print, copy and assembling rights. A ready to use command line utility is included.

NuGet · ExpertPdf.MergePdf C# & VB.NET samples included
Inputs PDFs + images
Output One PDF · memory or file
Targets .NET Framework to .NET 11

Everything PDF Merge does.

Append PDF documents, images and empty pages, set up the merged document and its security, and save it in memory or in a file.

Inputs & output

What goes in and what comes out.

PDF documents, images and empty pages, appended in any order. One PDF document out.

Merge PDF documents

Append existing PDF documents from files or streams, whole or only a range of their pages. Password protected documents can be appended with their password.

Merge images with PDF files

Append images in any format, from a file or as a System.Drawing.Image object. Each element starts on a new page.

Empty pages

Append an empty page between the other elements of the merged document.

Merge from memory

Append PDF documents given as byte arrays, whole or a range of their pages, with their password when they are protected.

Insert at any position

Insert a document, a page range, an image or an empty page anywhere in the merged document, not only at the end.

Reorder pages

Change the order of the merged pages with ReorderPages; bookmarks follow their pages.

Save in memory or in a file

Get the merged document as a byte array, write it to a stream, or save it to a file.

Multithreading support

The library supports multithreading, so several merges can run from different threads of your application.

Document settings

How the merged document is set up.

Page size, orientation and compression, document information, passwords and rights.

Page size and orientation

Set the PDF page size (A4, Letter, Legal and the other standard sizes) and the orientation of the new pages, such as the pages created for images.

Compression level

Set the PDF compression level, from no compression to the best compression.

Document information

Set the title, author, subject, keywords and creation date of the merged document.

Password and rights

Password protect the merged document and set its rights to print, copy and assemble.

PDF/A and PDF/X

Save the merged document as PDF/A-1b, 2b, 3b, 3u or PDF/X-1a for archiving and printing.

A bookmark per document

Add a bookmark for each merged document, titled from its file name or its document title, and keep or drop the bookmarks of the sources.

Booklets

Print-ready booklets: two pages per landscape sheet in saddle-stitch order, for one-sided or two-sided printing.

Command line

A ready to use merge tool.

For combining documents and images without writing your own application.

Command line sample

Specify the merge elements, PDF files, images and empty pages, in any order with a simple syntax.

Full source code

The command line sample comes with its full C# and VB.NET source for .NET Framework, and a .NET 10 version.

Several files in. One PDF out.

Create a PDFMerge object, append the elements one by one, then save the merged document. Console and Windows Forms samples in C# and VB.NET ship with the download.

Program.cs · C#
using ExpertPdf.MergePdf;

// Page size, orientation and compression of the merged document
var options = new PdfDocumentOptions();
options.PdfPageSize = PdfPageSize.A4;
options.PdfPageOrientation = PDFPageOrientation.Portrait;
options.PdfCompressionLevel = PDFCompressionLevel.Normal;

var pdfMerge = new PDFMerge(options);
pdfMerge.LicenseKey = "your license key";

// Each element starts on a new page, in the order it is appended
pdfMerge.AppendPDFFile(@"C:\Docs\cover.pdf");
pdfMerge.AppendImageFile(@"C:\Docs\photo.jpg");
pdfMerge.AppendEmptyPage();
pdfMerge.AppendPDFFile(@"C:\Docs\contract.pdf");

pdfMerge.SaveMergedPDFToFile(@"C:\Docs\merged.pdf");

Install with dotnet add package ExpertPdf.MergePdf, or reference epmergepdf.dll from the download. The API reference describes every class and method.

Merge questions, answered.

Common questions about inputs, output, document settings and security.

What can be merged?
PDF documents, from files, streams or byte arrays, images, from files or as System.Drawing.Image objects, and empty pages. Each element starts on a new page of the merged document.
Can I insert or reorder pages?
Yes. InsertPDFFile, InsertPDFStream and InsertPDFBytes insert a document or a range of its pages at any position, InsertImageFile and InsertEmptyPage insert an image or an empty page, and ReorderPages changes the order of the merged pages. Bookmarks follow their pages.
Can it make a booklet?
Yes. With BookletOptions.Enabled the merged pages are placed two per landscape sheet in saddle-stitch order, ready to fold, with an optional order for two-sided printing (TwoSided).
Can the merged document be PDF/A?
Yes. Set PdfDocumentOptions.PdfStandardSubset to PDF/A-1b, 2b, 3b, 3u or PDF/X-1a.
In what order do the elements appear?
In the order you append them. Call AppendPDFFile, AppendPDFStream, AppendImageFile, AppendImageObject and AppendEmptyPage in the order the pages should have.
Can I merge only some pages of a PDF document?
Yes. AppendPDFFile and AppendPDFStream have overloads that take a zero based start index and a number of pages, and overloads that take the password of a protected source document.
Can I keep the merged document in memory?
Yes. RenderMergedPDFDocument returns the merged document as a byte array, SaveMergedPDFToStream writes it to a stream and SaveMergedPDFToFile saves it to a file.
Can I protect the merged document?
Yes. With the SecurityOptions property you set the user and owner passwords and the rights to print, copy and assemble the document.
Is there a command line tool?
Yes. A command line sample, with full C# and VB.NET source for .NET Framework and a .NET 10 version, combines documents and images without writing code. You specify the merge elements in any order with a simple syntax.
Which .NET versions are supported?
.NET Framework, .NET Core and .NET 5 to .NET 11. The download has the libraries for .NET 2.0, .NET 4.0 and .NET Standard 2.0, the last one for .NET Core and .NET 5 to .NET 11. The library runs on Windows.
Can I try it before buying?
Yes. Download the free trial with the C# and VB.NET samples, and license it on the pricing page when you are ready.

Merge PDF documents from .NET.

Download the free trial with C# and VB.NET samples and the command line utility. When you are ready, license MergePDF on the pricing page.

Targets.NET Framework · .NET Core · .NET 5 to 11
Versionv10.0.0