Skip to content
ComPDF
DemoAPI ReferenceFAQ

PDF Generation Template Editor

Open-source visual PDF generation engine with customizable templates and developer-friendly APIs.

View on GitHub

PDF to Image API

Feature

Request Mode

ItemValue
Authenticationx-api-key: your_api_key_here
Request URLPOST http://localhost:8080/api/v1/process/pdf/png
Content typemultipart/form-data
Success responsePNG or image archive file stream

Request Parameters

ParameterTypeDescriptionRequired
fileFileSource file. Recommended extension: .pdf.Yes
optionsStringJSON string containing the feature options below.No
passwordStringSource file open password, used for password-protected PDFs.No

Options Parameters

Put the following fields in the options JSON string.

ParameterTypePurpose
imageFormatStringImage output format. Supported values include JPG, JPEG, JPEG2000, PNG, BMP, TIFF, TGA, GIF, WEBP. The ComPDF Self-hosted uppercases this value before forwarding.
imageScalingNumberImage scaling ratio for PDF to image. The ComPDF Web calculates this from DPI as DPI / 72.
pageRangesStringPage ranges to process, starting from page 1. Examples: 1, 1-3, 1,3-5. Empty means all pages.
outputFileNameStringOptional output filename. When present, it is used as the preferred download filename.

Request Example

bash
curl -X POST "http://localhost:8080/api/v1/process/pdf/png" \
  -H "x-api-key: your_api_key_here" \
  -F "[email protected]" \
  -F 'options={"imageFormat":"PNG","imageScaling":2,"pageRanges":""}'

Response

On success, the API returns the converted file stream with Content-Type and Content-Disposition headers. On failure, ComPDF Self-hosted returns the normalized error response described in Definition of Error Codes, including type, code, errorCode, message, and traceId.