Skip to content
ComPDF
DemoFAQ
New Release

Open-Source PDF SDK & AI Document Processing

Get the full self-hosted SDK and AI document processing on GitHub. One-click deploy to quickly build your document workflows.

Convert PDF to Image

Overview

ComPDF Conversion SDK provides an API for converting PDFs to images. Integrate ComPDF Conversion SDK to your apps to convert PDF into images easily.

Setting Image Formats

In ComPDF Conversion SDK, supported image formats include:

  • JPG
  • JPEG
  • JPEG2000
  • PNG
  • BMP
  • TIFF
  • TGA
  • GIF
  • WEBP

Setting Image Color Modes

Supported image color modes in ComPDF Conversion SDK include:

  • Color: Color mode, where the image effect is consistent with the original PDF page.
  • Gray: Grayscale mode.
  • Binary: Black and white mode, which applies binarization to the original effect.

Setting Image Scaling

The SDK supports setting image scaling. The default scaling is 1.0, which maintains the original PDF page size. If you want to double the image size, you can set image_scaling to 2.0; similarly, to reduce the image size by half, set image_scaling to 0.5.

Enhancing Image Path Display

The SDK supports an option called image_path_enhance for enhancing the display of image paths. This option can be enabled when you want to enhance the display effect of paths within the PDF page.

  • Do not enable the image_path_enhance option (original PDF rendering effect):

    image-20250603162605558

  • Enable the image_path_enhance option:

    image-20250603162651769

Notice

  • A higher image_scaling value results in images with higher resolution, but it also increases memory usage and slows down the conversion.
  • A higher image_scaling value does not necessarily equate to higher clarity; the clarity also depends on the original image resolution in the document.

Sample

This sample demonstrates how to convert from a PDF to Image file.

python
input_file_path = "***"
password = "***"
output_file_name = "***"

image_options = ConvertOptions()
error = CPDFConversion.start_pdf_to_image(input_file_path, password, output_file_name, image_options)