optimize_pdf
Shrink PDF files by linearizing for web view, recompressing streams, and lowering image DPI or targeting a size limit while keeping text and drawings sharp.
Instructions
Shrink a PDF: linearize ("fast web view"), recompress object streams and, if asked, lower the resolution of its pictures (max_image_dpi), or keep lowering it until the file fits a size (target_size_mb, down to 72 dpi). Text and drawings stay sharp, except in scans, where the text is itself a picture and can become hard to read at low resolutions. Pictures whose placement can't be worked out, masks, palettes and CMYK are left as they are. Lowering resolution needs the owner password if the PDF forbids changes. Signed PDFs are refused.
Any password argument can be "ask": the user then types it on a local page, so it never passes through the chat.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"input_path": "<input_path>"
},
"name": "optimize_pdf"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| compress | No | ||
| password | No | ||
| linearize | No | ||
| overwrite | No | ||
| input_path | Yes | ||
| output_path | No | ||
| max_image_dpi | No | Lower the resolution of pictures drawn sharper than this many dots per inch (150 suits screens, 300 print). Lossy; leave out to keep pictures as they are. | |
| target_size_mb | No | Keep lowering picture resolution and JPEG quality until the file is at most this many MB (1 MB = 1,000,000 bytes). Lossy. The smallest result is saved even if the target can't be met; check target_met. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| pages | Yes | ||
| output | Yes | ||
| image_dpi | Yes | ||
| linearized | Yes | ||
| size_after | Yes | ||
| target_met | Yes | ||
| saved_bytes | Yes | ||
| size_before | Yes | ||
| images_resampled | Yes | ||
| target_size_bytes | Yes | ||
| password_protected | Yes | ||
| user_password_changed | Yes | ||
| permissions_restricted | Yes |