Convert PDF Pages to BMP Images in Python

Import a PDF document and render every page as a BMP image with Aspose.Slides for Python via Java.

Convert PDF to BMP in Python

Aspose.Slides for Python via Java can import PDF pages as slides, render each slide, and save the rendered content as a BMP image. The conversion does not require Microsoft PowerPoint or a PDF viewer.

Convert PDF to BMP using Python

Create an empty Presentation, remove its default slide, and call addFromPdf to import the PDF pages. Then access each slide through a variable, call getImage, and save the rendered image with ImageFormat.Bmp.

Python code for converting PDF pages to BMP

presentation = Presentation()
try:
    presentation.getSlides().removeAt(0)
    presentation.getSlides().addFromPdf("document.pdf")

    slide_count = presentation.getSlides().size()

    for slide_index in range(slide_count):
        slide = presentation.getSlides().get_Item(slide_index)
        slide_image = slide.getImage(2, 2)
        try:
            file_path = f"page-{slide_index + 1}.bmp"
            slide_image.save(file_path, ImageFormat.Bmp)
        finally:
            slide_image.dispose()
finally:
    presentation.dispose()

How to convert PDF pages to BMP images in Python

Follow these steps to import a PDF document and render its pages as separate BMP images.

  1. Install Aspose.Slides for Python via Java .

  2. Configure the package and start the Java Virtual Machine in your application.

  3. Import the PDF pages by calling addFromPdf on the presentation’s slide collection.

  4. Access each slide through a variable, call getImage, and save the result with ImageFormat.Bmp.