# Convert PNG to PDF in PHP

> Place a PNG image on a presentation slide and export it as PDF in PHP with Aspose.Slides for PHP via Java.

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



## Convert PNG to PDF in PHP

[**Aspose.Slides for PHP via Java**](/slides/php-java/) lets you place a PNG image on a presentation slide at its original dimensions and export the result as a PDF document.

The PNG remains embedded as an image on the slide, while `SaveFormat::Pdf` exports the complete presentation to PDF.

## Convert PNG to PDF using PHP

Create a `Presentation`, load the PNG with `Images::fromFile`, match the slide size to the image with `setSize`, add the image with `addPictureFrame`, and call `save` with `SaveFormat::Pdf`.

### PHP code for converting PNG into PDF

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

    $sourceImage = Images::fromFile("input.png");
    try {
        $embeddedImage = $presentation->getImages()->addImage($sourceImage);
    } finally {
        $sourceImage->dispose();
    }

    $imageWidth = java_values($embeddedImage->getWidth());
    $imageHeight = java_values($embeddedImage->getHeight());

    $presentation->getSlideSize()->setSize(
        $imageWidth, $imageHeight, SlideSizeScaleType::DoNotScale);

    $slide->getShapes()->addPictureFrame(
        ShapeType::Rectangle, 0, 0, $imageWidth, $imageHeight, $embeddedImage);

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

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

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

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

Create a `Presentation`, access its first slide, and load the PNG with `Images::fromFile`.

Set the slide dimensions with `setSize`, then place the image on the slide with `addPictureFrame`.

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

## Convert PNG To Other Supported Formats

- [PNG TO HTML](/slides/php-java/conversion/png-to-html/)
- [PNG TO JPG](/slides/php-java/conversion/png-to-jpg/)
- [PNG TO SVG](/slides/php-java/conversion/png-to-svg/)
- [PNG TO PPT](/slides/php-java/conversion/png-to-ppt/)
- [PNG TO PPTX](/slides/php-java/conversion/png-to-pptx/)
