Merge PDF Files in PHP

Combine multiple PDF documents with Aspose.Slides for PHP via Java.

Merge PDF to PDF in PHP

Create a Presentation, remove its default slide, import each PDF with addFromPdf, and save the combined content with SaveFormat::Pdf.

PHP code for merging PDF to PDF

$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 PHP via Java can import pages from multiple PDF documents into a single Presentation and export the combined slides as one PDF file.

How to merge PDF files in PHP

Follow these steps to merge multiple PDF files into one PDF in PHP.

  1. Install Aspose.Slides for PHP via Java. See Installation.
  2. Configure Aspose.Slides in your PHP project.
  3. Create a Presentation instance and remove its default slide.
  4. Import each PDF file with addFromPdf.
  5. Call save with the output file path and SaveFormat::Pdf.

Built with Aspose.Slides

Merge PDF Files Online

The free Aspose.Slides Merger app is built with Aspose.Slides for PHP via 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 supported formats.