Convert PDF to BMP in Python

Python API for converting PDF pages to BMP images

Convert PDF to BMP in Python

Aspose.Slides for Python via .NET lets you convert PDF pages to BMP images programmatically. Import the PDF pages into a Presentation by using SlideCollection.add_from_pdf, render each imported slide with Slide.get_image, and save the resulting IImage object in BMP format.

This workflow creates one BMP file for each page in the source PDF. You can test the conversion in your browser or use the Python API in your application.

Install the library from PyPI by using the following command:

Console/Terminal

pip install aspose-slides

Save PDF as BMP in Python

Use the free online app to see the PDF-to-BMP conversion process in action.

This sample code shows how to convert PDF to BMP in Python

image_scale = 2

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}.bmp"
        with slide.get_image(image_scale, image_scale) as slide_image:
            slide_image.save(file_path, slides.ImageFormat.BMP)

How to Convert PDF to BMP in Python

Follow these steps to convert a PDF file to BMP using Python.

  1. Create a Presentation, remove its default slide, and import the PDF by using SlideCollection.add_from_pdf.
  2. Iterate through Presentation.slides and render each imported page by using Slide.get_image.
  3. Save each rendered image by using IImage.save with ImageFormat.BMP.

System Requirements

Before running the Python conversion sample, make sure your environment meets these requirements.

  • Microsoft Windows, macOS, or 64-bit Linux (see the system requirements ).
  • Python 3.6 or later for this sample.
  • Aspose.Slides for Python via .NET installed in your environment.