Merge PDF in Java

Use Aspose.Slides for Java to merge PDF files in Java applications.

Merge PDF to PDF in Java

Using Aspose.Slides for Java , you can merge PDF files and create a PDF result with a few lines of Java code.

Java code for merging PDF to PDF

Presentation presentation = new Presentation();
try {
    presentation.getSlides().removeAt(0);
    presentation.getSlides().addFromPdf("document1.pdf");
    presentation.getSlides().addFromPdf("document2.pdf");

    presentation.save("merged.pdf", SaveFormat.Pdf);
} finally {
    presentation.dispose();
}

Merge PDF to PDF using Aspose.Slides

Aspose.Slides for Java is a Java API for creating, editing, converting, and merging presentation content. You can place PDF files into a Presentation and import multiple PDF files and save them as one PDF file.

How to merge PDF files in Java

  1. Install Aspose.Slides for Java.
  2. Add the library as a reference in your project.
  3. Create a Presentation instance.
  4. Import the source PDF files with addFromPdf.
  5. Save the merged content with SaveFormat.Pdf.

Built with Aspose.Slides

Merge PDF Files Online

The free Aspose.Slides Merger app is built with Aspose.Slides for Java, the same API as the code above. Open it and see what the API can do with your own PDF files.

  • Runs in your browser, nothing to install.
  • See how Aspose.Slides merges files before you write code.
  • Upload several PDF files and combine them into one.
  • Download the merged result as one file.

Merge other files

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