PDF tools

Compress

POST /v1/pdf/compress — shrink files without losing quality.

POST /v1/pdf/compress optimizes a PDF's internal structure (object streams, unused resources) and returns a lighter file.

Request

PDF=$(base64 -w0 heavy.pdf)     # macOS: base64 -i heavy.pdf

curl -X POST https://api.pdf-forge.dev/v1/pdf/compress \
  -H "Authorization: Bearer $PDFFORGE_API_KEY" \
  -H "Content-Type: application/json" \
  -d "{\"pdf\": \"$PDF\"}" \
  --output compressed.pdf
FieldTypeDescription
pdfstringRequired. The PDF, base64-encoded.

Response

The compressed PDF binary. Two headers let you measure the gain without opening the file:

X-PDF-Original-Size: 4823041
X-PDF-Size: 1204523
# Quick before/after check
curl -s -D - -o compressed.pdf ... | grep -i x-pdf

Lossless by design

Compression is structural: no image downsampling, no font subsetting that would alter rendering. A file that is already optimized may barely shrink.

Next steps

  • Inspect — see what makes the file heavy (image DPI, embedded fonts) before compressing.
  • Assemble & split — remove pages you don't need.
  • Secure — protect the compressed file.

On this page