Merge PDF in Java

High-speed and cross-platform Java library for merging PDF files using Java code

Merge PDF to PDF using Aspose.Slides

Aspose.Slides for Java is a powerful Java library used to create, convert, merge, and manipulate presentations, PDFs, and other documents. When you merge PDF to PDF, you are effectively combining pages from 2 documents to obtain one PDF file. Aspose.Slides allows you merge PDFs in different ways. You get to merge PDFs with all their shapes, styles, texts, formatting, etc.

Merge PDF to PDF in Java

Using Aspose.Slides for Java , you can merge PDF files quickly with just a few lines of code

Java code for merging PDF to PDF


Presentation pres = new Presentation();
try {
    pres.getSlides().addFromPdf("InputPDF1.pdf");
    pres.getSlides().addFromPdf("InputPDF2.pdf");

    pres.save("pres.pdf", SaveFormat.Pdf);
} finally {
    if (pres != null) pres.dispose();
}

How to merge PDF in Java

  1. Install Aspose.Slides for Java. See Installation .

  2. Add the library as a reference in your project.

  3. Create an instance of the Presentation class.

  4. Load the PDF files you want to merge.

  5. Save the resulting PDF.

Merge PDF Files Online

How to Merge PDF in Python

Merge other files

You can also combine files in other formats to get a single file