Syncfusion Feedback

Merge PDFs in C# with the .NET PDF Library

The Syncfusion® .NET PDF Library offers powerful capabilities for creating, reading, and editing PDF documents. Users can merge multiple PDF files into a single document, enabling simplified file management, consolidated content, and document organization.

Watch this video to see how to merge PDF files using the Syncfusion .NET PDF Library.

Watch the video

Merge and combine multiple PDF files in C#

Learn how to programmatically merge and combine multiple PDF documents into a single file in C# using the Syncfusion .NET PDF Library. This guide demonstrates PDF merging with preserved formatting and content.

Step 1: Create a new C# Console Application project

Begin by creating a new C# Console Application project in Visual Studio or your preferred IDE to implement PDF merging functionality.

Step 2: Install Syncfusion PDF NuGet package

Install the Syncfusion.Pdf.Net.Core NuGet package in your C# project from NuGet.org. This package provides the necessary APIs for merging multiple PDF documents.

Step 3: Add required namespace for PDF merging

Import the following namespace in your Program.cs file to access PDF document merging methods:

using Syncfusion.Pdf;

Step 4: Create a new PDF document for merging

Create a new PdfDocument object that will serve as the destination document for merging multiple PDF files.

//Creates a PDF document
using (PdfDocument document = new PdfDocument())
{
}

Step 5: Merge the PDF files

Create a string array containing the file paths of all PDF documents to be merged. Use the PdfDocumentBase.Merge method to combine all PDFs into the destination document, preserving content, formatting, and structure. Save and close the merged document.

Run

//Creates a string array of source files to be merged
string[] source = { Path.GetFullPath(@"Data/file1.pdf"), Path.GetFullPath(@"Data/file2.pdf") };
//Merges PDFDocument
PdfDocumentBase.Merge(document, source);
//Save the merged document
document.Save(Path.GetFullPath(@"Output/Output.pdf"));

NuGet installation

Nuget Installation image Syncfusion.Pdf.Net.Core Copy Icon image

Get started quickly by downloading the installer and checking license information on the Downloads page.

Syncfusion .NET PDF Library Resources

Explore these resources for comprehensive guides, knowledge base articles, insightful blogs, and ebooks.