Convert PDF to JPG in PHP

Import PDF pages and render them as JPG images with Aspose.Slides for PHP via Java

Convert PDF to JPG using PHP

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

PHP code for converting PDF into JPG

$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) . ".jpg";
            $slideImage->save($filePath, ImageFormat::Jpeg);
        } finally {
            $slideImage->dispose();
        }
    }
} finally {
    $presentation->dispose();
}

Convert PDF to JPG in PHP

Use Aspose.Slides for PHP via Java to import the pages of a PDF document as slides and render each slide as a JPG image.

Call addFromPdf to import the PDF pages, then call getImage for each slide and save the result with ImageFormat::Jpeg.

How to convert PDF to JPG using Aspose.Slides for PHP API

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

  1. Install Aspose.Slides for PHP via Java with Composer.
  2. Create a Presentation and remove its default slide.
  3. Import the PDF pages with addFromPdf.
  4. Access each slide through a variable, call getImage, and save the rendered image with ImageFormat::Jpeg.

Built with Aspose.Slides

Convert PDF to JPG Online

The free Aspose.Slides Conversion app is built with Aspose.Slides for PHP via Java, the same API as the code above. Open it and see what the API can do with your own PDF files.

  • Runs in your browser, nothing to install.
  • See how Aspose.Slides converts files before you write code.
  • Upload PDF files and save them as JPG.
  • Download the result or convert more files.

Convert PDF To Other Supported Formats

You can also convert PDF and save to other file formats. See all supported formats below: