
Compress PDF API
File Tools
Make PDFs smaller in your browser by shrinking the images inside them. Text stays sharp and selectable, links and form fields keep working, and nothing is uploaded.
Authentication
All API requests require a valid API key passed in the Authorization header as a Bearer token.
Rate Limit
20 requests per minute
Endpoints
1 endpoint available
Overview
Make a PDF smaller. The same engine as the web page:
- light (150 DPI, quality 85), recommended (110 DPI, quality 72), strong (72 DPI, quality 55): images inside the PDF are scaled down to the target resolution and re-encoded as JPEG, only where that makes them smaller. Uncompressed streams are compressed and unused objects dropped. Text, links, bookmarks and form fields are kept.
- maximum (100 DPI, quality 60): every page becomes a JPEG picture. Smallest for scans, but text is no longer selectable and links, bookmarks and form fields are lost.
dpi and quality override the level's settings.
Response
The body is a PDF. If compression did not make the file smaller, the original file is returned unchanged. These headers describe the result:
X-Original-Size: input size in bytes.X-Output-Size: size of the returned file in bytes.X-Compressed:true, orfalsewhen the original was returned.
Limits
- One PDF up to 25 MB; 500 pages, or 100 pages for maximum.
- Password-protected or damaged PDFs return 422.
Endpoints
POST
https://opentools.ca/api/v1/tools/compress-pdfCompress a PDF by shrinking its images, or by turning pages into pictures
Request Body
Content-Type: multipart/form-data
| Parameter | Type | Required | Description |
|---|---|---|---|
| file | file | Required | The PDF to compress. |
| level | string Enum: light, recommended, strong, maximum | Optional | Compression level.Default: recommended |
| dpi | integer | Optional | Target image resolution, 36 to 300. Overrides the level. |
| quality | integer | Optional | JPEG quality, 20 to 95. Overrides the level. |
Response Example
The compressed PDF (Content-Type: application/pdf, filename <name>-compressed.pdf), or the original file when it could not be made smaller. Headers: X-Original-Size, X-Output-Size, X-Compressed.Error Codes
400
Bad Request - missing or invalid fields (see details)401
Unauthorized - missing or invalid API key403
Forbidden - API key inactive or expired, or request IP not allowed413
Payload Too Large - a file is over 25 MB415
Unsupported Media Type - the file is not a PDF422
Unprocessable - the PDF is damaged or password-protected, or has too many pages for the level429
Too Many Requests - more than 20 requests per minute for this key500
Internal Server ErrorCode Examples
curl -X POST https://opentools.ca/api/v1/tools/compress-pdf \
-H "Authorization: Bearer YOUR_API_KEY" \
-F "file=@brochure.pdf" \
-F "level=strong" \
-D headers.txt \
-o brochure-compressed.pdfRather use it in your browser? Open the Compress PDF