Optimize PDF documents by stripping unused XML metadata, flattening object streams, and slicing unused page ranges.
Need general upload and polling mechanics?
See File Conversion for multipart upload (POST /api/uploads), polling intervals, and download token authentication.
Browser Execution vs. REST API
pdf-lib without server upload. When automating via the REST API, call POST /api/conversions with jobIntent: "transform" and metadata: "remove" to optimize the PDF server-side.• Metadata Stripping: PDF documents often accumulate several megabytes of redundant XML metadata packets, Adobe Photoshop editing histories, and embedded thumbnail images. The metadata: "remove" option strips these streams while preserving vector curves and text streams.
• Page Slicing: Large multi-page reports can be compressed by extracting only the required pages using the pageRange parameter.
{
"fileId": "<FILE_ID>",
"toFormat": "pdf",
"jobIntent": "transform",
"options": {
"metadata": "remove"
}
}| Parameter | Type | Required | Description |
|---|---|---|---|
| fileId | string | Yes | The storage key returned by POST /api/uploads for the source PDF. |
| toFormat | string | Yes | Must be 'pdf'. Accepted: "pdf" |
| jobIntent | string | Yes | Must be set to 'transform' to allow same-format PDF optimization. Accepted: "transform" |
| options.metadata | string | No | Strips internal author, title, and creation timestamp metadata. Accepted: "remove" | "keep" |
| options.pageRange | string | No | Extracts and optimizes only specified pages (e.g. '1-5' or 'all'). Accepted: Expression like "1-5" or "all" |
| HTTP | Error Code | Cause & Resolution |
|---|---|---|
| 400 | SAME_FORMAT_NOOP | Missing jobIntent: 'transform' in request body. |
| 400 | CORRUPT_FILE | Uploaded PDF file is corrupted or cannot be parsed by pdf-lib. |
| 413 | FILE_TOO_LARGE | PDF document exceeds max upload size limit for plan. |
# Optimize and compress a PDF document by stripping metadata
curl -X POST "https://api.orbconvert.com/api/conversions" \
-H "Authorization: Bearer <API_KEY>" \
-H "Content-Type: application/json" \
-d '{
"fileId": "<FILE_ID>",
"toFormat": "pdf",
"jobIntent": "transform",
"options": {
"metadata": "remove"
}
}'Was this page helpful?