PlatformXeDocs
Get API Key

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

FieldTypeRequiredDescription
pdfBase64stringYesBase64-encoded PDF. Decodes to at most 10 MB and 20 pages.
formatstringYesjpeg or png.
pagenumberNo1-indexed page to render. Default: 1. Must be within the document's page range.
dpinumberNoRender 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
  }
}
FieldTypeDescription
imageBase64stringBase64-encoded rendered image.
contentTypestringimage/jpeg or image/png, matching the requested format.
widthnumberRendered image width in pixels.
heightnumberRendered image height in pixels.
pageCountnumberTotal 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

CodeHTTP statusDescription
VALIDATION_ERROR400Missing/invalid pdfBase64, invalid format, page not a positive integer, malformed PDF, or page out of the document's range
UNAUTHORIZED401Missing or invalid API key
FORBIDDEN403API key lacks the pdf:rasterize scope
RENDER_TIMEOUT408The page was well-formed but too complex to render within the time budget
PAYLOAD_TOO_LARGE413Decoded PDF exceeds 10 MB, the document has more than 20 pages, or the rendered page would exceed the 6000px-per-side cap
RATE_LIMITED429Exceeded 200 requests/hr for this API key
INTERNAL_ERROR500Unexpected 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.