Rasterize PDF
API reference for converting one page of a PDF into a JPEG or PNG image.
Convert one page of a base64-encoded PDF into a JPEG or PNG image. caldera-lettings uses this to let a corporate client download a rendered invoice PDF as a JPEG without a PDF renderer on the Lettings side — send the PDF bytes here and get an image back.
Endpoint
POST /api/v1/pdf/rasterize
Requires the pdf:rasterize scope, rate-limited to 200 requests/hr per API key — separate from the default 1,000/hr tier the rest of the PDF domain uses. See Authentication → Rate limits.
Request body
| Field | Type | Required | Description |
|---|---|---|---|
pdfBase64 | string | Yes | Base64-encoded PDF. Decodes to at most 10 MB and 20 pages. |
format | string | Yes | jpeg or png. |
page | number | No | 1-indexed page to render. Default: 1. Must be within the document's page range. |
dpi | number | No | Render resolution. Default: 150. Clamped server-side to [1, 300] — never rejected, just clamped to the nearest valid value. |
The rendered image's longest side is capped at 6000px regardless of the requested dpi. A page whose rendered size would exceed that cap fails with 413 PAYLOAD_TOO_LARGE rather than silently downscaling.
Response
{
"success": true,
"data": {
"imageBase64": "/9j/4AAQSkZJRgABAQAAAQABAAD...",
"contentType": "image/jpeg",
"width": 1240,
"height": 1754,
"pageCount": 3
}
}
| Field | Type | Description |
|---|---|---|
imageBase64 | string | Base64-encoded rendered image. |
contentType | string | image/jpeg or image/png, matching the requested format. |
width | number | Rendered image width in pixels. |
height | number | Rendered image height in pixels. |
pageCount | number | Total number of pages in the source PDF (not just the rendered page). |
Examples
curl
curl -X POST https://api.platformxe.com/api/v1/pdf/rasterize \
-H "Content-Type: application/json" \
-H "x-api-key: pxk_live_your_api_key_here" \
-d '{
"pdfBase64": "JVBERi0xLjcKCj...",
"format": "jpeg",
"page": 1,
"dpi": 150
}'
SDK
See /sdk/pdf for TypeScript, Python, and Go examples.
Error responses
| Code | HTTP status | Description |
|---|---|---|
VALIDATION_ERROR | 400 | Missing/invalid pdfBase64, invalid format, page not a positive integer, malformed PDF, or page out of the document's range |
UNAUTHORIZED | 401 | Missing or invalid API key |
FORBIDDEN | 403 | API key lacks the pdf:rasterize scope |
RENDER_TIMEOUT | 408 | The page was well-formed but too complex to render within the time budget |
PAYLOAD_TOO_LARGE | 413 | Decoded PDF exceeds 10 MB, the document has more than 20 pages, or the rendered page would exceed the 6000px-per-side cap |
RATE_LIMITED | 429 | Exceeded 200 requests/hr for this API key |
INTERNAL_ERROR | 500 | Unexpected server error |
dpi is a quality knob, not a correctness contract — an out-of-range value is clamped rather than rejected, so a caller never has to retry with a different number. Page count, page range, and payload size are the only inputs that can fail validation.