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.

Setting Image Formats

Supported image formats include JPG, JPEG, JPEG2000, PNG, BMP, TIFF, TGA, GIF, and WEBP.

ruby
options = ComPDFKitConversion::ConvertOptions.new
options.image_type = ComPDFKitConversion::ImageType::PNG

Setting Image Color Modes

Supported image color modes include Color, Gray, and Binary.

ruby
options.image_color_mode = ComPDFKitConversion::ImageColorMode::COLOR

Setting Image Scaling

The SDK supports setting image scaling. The default scaling is 1.0.

ruby
options.image_scaling = 2.0

Enhancing Image Path Display

Use image_path_enhance to enhance the display effect of paths within the PDF page.

ruby
options.image_path_enhance = true

Sample

ruby
options = ComPDFKitConversion::ConvertOptions.new
options.image_type = ComPDFKitConversion::ImageType::PNG

result = ComPDFKitConversion::Conversion.start_pdf_to_image(
  input_file_path,
  "",
  output_file_path,
  options
)