Convert PDF to PNG in PHP
Import PDF pages and render them as PNG images with Aspose.Slides for PHP via Java
Convert PDF to PNG 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 PNG image.
Call addFromPdf to import the PDF pages, then call getImage for each slide and save the result with ImageFormat::Png.
Convert PDF to PNG using PHP
Create a Presentation, remove its default slide, import the PDF pages, and save a PNG image for each imported slide.
PHP code for converting PDF into PNG
$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 PNG using Aspose.Slides for PHP API
These are the steps to convert PDF to PNG in PHP.
Install Aspose.Slides for PHP via Java with Composer.
Create a
Presentationand remove its default slide.Import the PDF pages with
addFromPdf.Access each slide through a variable, call
getImage, and save the rendered image withImageFormat::Png.
Free Online PDF Converter
Convert PDF To Other Supported Formats
You can also convert PDF and save to other file formats. See all supported formats below: