PDF Merger via C#

Merge documents. Use Aspose.PDF for .NET to modify PDF files programmatically

How to Merge PDF files Using .NET

In order to merge PDF file, we’ll use Aspose.PDF for .NET API which is a feature-rich, powerful and easy-to-use document manipulation API for net platform. Our .NET Library can convert a document from any supported download format to any supported save format. Aspose.PDF for .NET library provides fairly universal solutions that will help you solve the tasks of converting documents. Aspose.PDF supports the largest number of popular document formats, both for loading and saving. Draw your attention that the current section describes only popular conversions. The current page provides information about converting format to format. However, there are many combinations for converting your files. For a complete list of supported formats, see the section Supported File Formats. Open NuGet package manager, search for Aspose.PDF and install. You may also use the following command from the Package Manager Console.

Package Manager Console

PM > Install-Package Aspose.PDF

Merge PDF files via C#


You need Aspose.PDF for .NET to try the code in your environment.

  1. Open first document.
  2. Open second document.
  3. Add pages of second document to the first.
  4. Save concatenated output file

C# - example code to merge PDF files


    // Open first document
    Document pdfDocument1 = new Document(_dataDir + "Concat1.pdf");
    // Open second document
    Document pdfDocument2 = new Document(_dataDir + "Concat2.pdf");

    // Add pages of second document to the first
    document1.Pages.Add(document2.Pages);
    
    dataDir = dataDir + "ConcatenatePdfFiles_out.pdf";
    // Save concatenated output file
    pdfDocument1.Save(dataDir);