# Merge Images to PDF in PHP

> Merge multiple images into a single PDF document in PHP with Aspose.Slides for PHP via Java.

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



## Merge Images to PDF using Aspose.Slides

[**Aspose.Slides for PHP via Java**](/slides/php-java/) lets you place each source image on a separate presentation slide and export all the slides as a single multi-page PDF document.

## Merge Images to PDF in PHP

Load each source file with `Images::fromFile`, add a slide with `addEmptySlide`, place the image with `addPictureFrame`, and call `save` with `SaveFormat::Pdf`.

### PHP code for merging images into PDF

```php
$presentation = new Presentation();
try {
    $presentation->getSlides()->removeAt(0);
    $layoutSlide = $presentation->getLayoutSlides()->get_Item(0);

    $imagePaths = ["image1.png", "image2.jpg"];
    foreach ($imagePaths as $imagePath) {
        $slide = $presentation->getSlides()->addEmptySlide($layoutSlide);

        $sourceImage = Images::fromFile($imagePath);
        try {
            $presentationImage = $presentation->getImages()->addImage($sourceImage);
        } finally {
            $sourceImage->dispose();
        }

        $slide->getShapes()->addPictureFrame(
            ShapeType::Rectangle, 0, 0, 720, 540, $presentationImage);
    }

    $presentation->save("merged-images.pdf", SaveFormat::Pdf);
} finally {
    $presentation->dispose();
}
```

## How to merge images to 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`, remove its default slide, and access a layout slide.

Load each source image with `Images::fromFile`, add an empty slide with `addEmptySlide`, and place the image with `addPictureFrame`.

Save the presentation with `SaveFormat::Pdf`.

## Merge Other Files
