Compress a PDF
POST/pdf/compress
Rewrites a PDF to make it smaller without losing anything: objects packed into compressed
streams, identical streams stored once, images recompressed losslessly and fonts cut down to
the glyphs the document shows. Image quality is never lowered. When the rewrite is not
smaller, the render keeps the source as it was, so its bytes are the source's. The source is a
stored PDF named as source in a JSON body, or an upload as multipart/form-data with the PDF
as file (never stored). Costs 0.5 units on live keys; Starter plan and above. A PDF/A
answers 422 source_invalid, a signed or password-protected PDF 422 source_invalid or
source_encrypted. Needs render:create.
Request
Responses
- 200
- 413
- 415
- 422
- 429
- 503
- default
The render of the smaller PDF.
The upload is larger than the plan's output size or 100 MB.
file_type_unsupported: the upload is no PDF.
source_not_found, source_invalid (unreadable, signed, or a PDF/A), source_encrypted, page_limit_exceeded, output_too_large.
rate_limited: the workspace's bucket of the plan's requests per second is empty (Free test keys also have 30 a minute). The problem names the bucket's limit and its window_seconds. Retry after Retry-After seconds.
Response Headers
Seconds until a request is let through again.
Size of the workspace's request bucket: the plan's requests per second. Free test keys are also held to 30 requests a minute, and the headers then describe whichever bucket is closer to empty.
Requests left in the bucket.
Seconds until the bucket is full again.
tool_unavailable: the PDF tools are busy; retry after Retry-After seconds.
Error (RFC 9457 problem details).