Merge PDF API

Combine multiple PDF files as separate documents with free cross-platform Apps and APIs. Native APIs to combine PDF files using .NET, .NET Core, Java, C++ & Android

How to Merge PDF files Using Aspose.PDF Library

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

High Code APIs to Combine Document Data

Native APIs to combine PDF files using .NET, .NET Core, Java, C++ & Android. Merging one or more PDF documents is a very popular task. The Aspose.PDF library does an excellent job with it. The example is written in C#, but the API can be used in other .NET programming languages such as VB.NET. PDF files are merged in such a way that the first one is joined at the end of the other document. Aspose.PDF shows combining files of various formats. Follow the link and get acquainted with all the possibilities of combining files with the Aspose.PDF library. There are many reasons why you might want to merge PDF files. For example, merging PDF files allows you to print a single file instead of queuing multiple documents for printing, while merging related files simplifies the process of managing and storing many documents by reducing the number of files you need to search for and organize.

Try to merge PDF files via C#

Example code for merging PDF files in C#

Combine PDF via C# with Aspose.PDF for .NET Library.

C# example

// 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);
document.Save(_dataDir+"ConcatenatedPDF.pdf");

Try to merge PDF files via Java

Example code to Merge PDF files in Java.

Combine PDF via Java with Aspose.PDF for Java Library.

Java example

// Create PdfFileEditor object
PdfFileEditor fileEditor = new PdfFileEditor();
String[] files = new String[] { "file1.pdf", "file2.pdf", "pdf3.pdf" };
// Merge multiple PDF files
fileEditor.concatenate(files, "merged-pdf.pdf");

Try to merge PDF files via C++

Example code to Merge PDF files in C++.

Combine PDF via C++ with Aspose.PDF for C++ Library.

C++ example

// Open first document
auto doc1 = MakeObject<Document>(u"file1.pdf");

// Open second document
auto doc2 = MakeObject<Document>(u"file2.pdf");

// Add pages of second document to the first
doc1->get_Pages()->Add(doc2->get_Pages());

// Save concatenated output file
doc1->Save(u"merged-output.pdf");

Try to merge PDF files via Python

Example code to Merge PDF files in Python.

Combine PDF via Python with Aspose.PDF for .NET in Python Library.

Python example

import aspose.pdf as ap
# Open first document
document1 = ap.Document(input_pdf_1)
# Open second document
document2 = ap.Document(input_pdf_2)

# Add pages of second document to the first
document1.pages.add(document2.pages)

# Save concatenated output file
document1.save(output_pdf)