Aspose.PDF  for .NET

Merge PDF Documents in C#

Merge two PDF files into one using C# without the use of any software like Adobe PDF.

How to Merge Multiple PDF Files Using C#

In order to merge PDFs in C#, we’ll use Aspose.PDF for .NET API which is a feature-rich, powerful and easy to use document manipulation and merging API for C# platform. Open NuGet package manager, search for Aspose.PDF and install. You may also use the following command from the Package Manager Console.


PM> Install-Package Aspose.PDF

Steps for Merging PDF Files in C#

A basic merging pdfs programmatically with Aspose.PDF for .NET APIs can be done with just few lines of code.

  • Load all the PDF files with full path.
  • Make one document as the base file
  • Call the relevant method for concatenating and merging files one by one.
  • Call the Save() method and pass the file name (full path) and format (PDF) as a parameter.
  • Now you can open and use the PDF file in Microsoft Office, Adobe PDF or any other compatible program.

System Requirements

Before executing the code below, please make sure that you have the following prerequisites on your system.

  • Microsoft Windows or a compatible OS with .NET Framework, .NET Core
  • Development environment like Microsoft Visual Studio
  • Include Aspose.PDF for .NET DLL reference in your project
  • Add namespace in relevant class

Merge Two PDF Files - C#

    // Open first document
    Document merge_file1 = new Document("PDF1.pdf");
    // Open second document
    Document merge_file2 = new Document("PDF2.pdf");
    // Add pages of second document to the first
    // Save concatenated output file


About Aspose.PDF for .NET API

Aspose.PDF API can be used for PDF document manipulation, parsing and concatenation within applications. One can create, modify, combine, secure, print or save PDF to TXT, HTML, PCL, XFA, XML, XPS, EPUB, TEX, Images and more formats. Aspose.PDF is a standalone API and it does not depend on any software including Adobe Acrobat. ‎

Online PDF Merger Live Demos