xtract.bot
POST /api/pdf-compress

Shrink a PDF by re-compressing embedded images. Configurable image quality (1–100). Lossless for vector / text content; lossy only for raster images at the requested quality.

Reduces a PDF's file size, primarily by re-compressing the images embedded inside it. Vector content (text, shapes, fonts) is untouched and stays pixel-perfect. Set `quality` 1–100 to control the JPEG re-encode applied to embedded raster images. `75` is a good default (visually similar to the original, ~50–80% smaller). `40` is acceptable for screen viewing. `90+` gives near-lossless results with modest savings. Encrypted source PDFs are rejected by default — pass `ignoreEncryption: true` to load them anyway.

Inputs

NameTypeDefaultDescription
pdf*fileThe PDF to compress.
dropMetadatabooleanfalseStrip /Info, /Metadata, and XMP packets.

Response

Modes: binary, base64-json. Cache: yes (24h TTL).

Code samples

Built from the default-compress example.

# Download or substitute the example input:
#   curl -O https://xtract.bot/examples/pdf-extract-text/hello.pdf
PDF=$(base64 -w0 < hello.pdf)

curl -X POST https://api.xtract.bot/api/pdf-compress \
  -H "Content-Type: application/json" \
  -H "Accept: application/octet-stream" \
  -H "X-Account-Id: $XTRACT_ACCOUNT_ID" \
  -H "X-Api-Key: $XTRACT_API_KEY" \
  -d '{
  "dropMetadata": false,
  "pdf": "'"$PDF"'"
}'