# Merge PDF Files in PHP

> Merge multiple PDF files into one PDF in PHP with Aspose.Slides for PHP via Java.

Source: https://products.aspose.com/slides/php-java/merger/pdf-to-pdf/
Updated: 2026-07-20



## Merge PDF to PDF using Aspose.Slides

[**Aspose.Slides for PHP via Java**](/slides/php-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

```php
$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.

Install **Aspose.Slides for PHP via Java**. See [**Installation**](https://docs.aspose.com/slides/php-java/installation/).

Configure Aspose.Slides in your PHP project.

Create a `Presentation` instance and remove its default slide.

Import each PDF file with `addFromPdf`.

Call `save` with the output file path and `SaveFormat::Pdf`.

## Merge Other Files
