Convert PDF to Image in Python
Import PDF pages and render them as images with a cross-platform Python API
Convert PDF to Image in Python
Aspose.Slides for Python via .NET
lets you convert PDF pages to raster images programmatically. The API provides SlideCollection.add_from_pdf for importing PDF content and Slide.get_image for rendering each imported page.
The example below saves each PDF page as a separate PNG image. You can select another supported raster format by changing the output extension and the ImageFormat value.
Convert PDF to Image using Python
Create a Presentation, remove its default blank slide, import the PDF pages, and render each imported Slide as an image.
Python code for converting PDF into Image
with slides.Presentation() as presentation:
presentation.slides.remove_at(0)
presentation.slides.add_from_pdf("document.pdf")
for slide in presentation.slides:
file_path = f"document_page_{slide.slide_number}.png"
with slide.get_image() as slide_image:
slide_image.save(file_path, slides.ImageFormat.PNG)
How to Convert PDF to Images Using the Aspose.Slides Python API
These are the steps to convert PDF pages to images in Python.
Install Aspose.Slides for Python via .NET .
Create a
Presentationand remove its default blank slide.Import the source PDF by using
SlideCollection.add_from_pdf.Render each imported
SlidewithSlide.get_imageand save it by usingIImage.save.
Convert PDF to Other Supported Formats
You can also convert PDF documents to other supported formats.