PDF to Image API
Feature
Request Mode
| Item | Value |
|---|---|
| Authentication | x-api-key: your_api_key_here |
| Request URL | POST http://localhost:8080/api/v1/process/pdf/png |
| Content type | multipart/form-data |
| Success response | PNG or image archive file stream |
Request Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
file | File | Source file. Recommended extension: .pdf. | Yes |
options | String | JSON string containing the feature options below. | No |
password | String | Source file open password, used for password-protected PDFs. | No |
Options Parameters
Put the following fields in the options JSON string.
| Parameter | Type | Purpose |
|---|---|---|
imageFormat | String | Image output format. Supported values include JPG, JPEG, JPEG2000, PNG, BMP, TIFF, TGA, GIF, WEBP. The ComPDF Self-hosted uppercases this value before forwarding. |
imageScaling | Number | Image scaling ratio for PDF to image. The ComPDF Web calculates this from DPI as DPI / 72. |
pageRanges | String | Page ranges to process, starting from page 1. Examples: 1, 1-3, 1,3-5. Empty means all pages. |
outputFileName | String | Optional 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, the ComPDF Self-hosted returns a normalized error JSON response.