Merge PDF Files in PHP

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

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.

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();
}

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.

Merge Other Files

You can also combine files in other supported formats.