# Convert PDF to Image in PHP

> Convert PDF pages to image files in PHP with Aspose.Slides for PHP via Java.

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



## Convert PDF to Image in PHP

Use [**Aspose.Slides for PHP via Java**](/slides/php-java/) to import the pages of a PDF document as slides and render each slide as an image.

Call `addFromPdf` to import the PDF pages and `getImage` to render them. The example below saves the rendered pages as PNG images, and you can select another supported image format when needed.

## Convert PDF to Image using PHP

Create a `Presentation`, remove its default slide, import the PDF pages, and save an image for each imported slide.

### PHP code for converting PDF pages into images

```php
$presentation = new Presentation();
try {
    $presentation->getSlides()->removeAt(0);
    $presentation->getSlides()->addFromPdf("document.pdf");

    $slideCount = java_values($presentation->getSlides()->size());
    for ($slideIndex = 0; $slideIndex < $slideCount; $slideIndex++) {
        $slide = $presentation->getSlides()->get_Item($slideIndex);
        $slideImage = $slide->getImage(2.0, 2.0);

        try {
            $filePath = "slide_" . ($slideIndex + 1) . ".png";
            $slideImage->save($filePath, ImageFormat::Png);
        } finally {
            $slideImage->dispose();
        }
    }
} finally {
    $presentation->dispose();
}
```

## How to convert PDF to Image using Aspose.Slides for PHP API

These are the steps to convert PDF to Image in PHP.

Install [**Aspose.Slides for PHP via Java**](/slides/php-java/) with Composer.

Create a `Presentation` and remove its default slide.

Import the PDF pages with `addFromPdf`.

Access each slide through a variable, call `getImage`, and save the rendered image with `ImageFormat::Png` or another supported format.

## Convert PDF To Other Supported Formats

- [PDF TO JPG](/slides/php-java/conversion/pdf-to-jpg/)
- [PDF TO PNG](/slides/php-java/conversion/pdf-to-png/)
- [PDF TO XML](/slides/php-java/conversion/pdf-to-xml/)
