Extract pages from PDF
pdf_extract_pagesExtract specified pages from a PDF into a new document in the exact order listed, allowing reordering or duplication; the source file is left unchanged.
Instructions
Keep only the listed pages of a PDF, in the order given, and return them as a new PDF. Because order follows the spec, it also reorders pages ("3,1,2") and can duplicate them. Use this to pull a section out of a document; use pdf_delete_pages to remove pages instead, pdf_split for several output files, and pdf_merge to join documents. Returns the result written to output_path, or inline as an application/pdf resource when output_path is omitted (results over 7 MB are never returned inline: pass output_path); an existing file at output_path is overwritten. The source is never modified. Fails with invalid_pages if a page is out of range.
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": {
"pdf_path": "<pdf_path>",
"pages": "<pages>"
},
"name": "pdf_extract_pages"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| pages | Yes | 1-based page spec, e.g. "1-3,5,8-" (open-ended range runs to the last page) | |
| password | No | Password to open the input, only needed for a user-password PDF (owner-locked files with an empty user password open without it). | |
| pdf_path | Yes | PDF source: a path to a .pdf file inside the allowed directories (PDFOPS_ROOT, default the working directory), an https:// URL, or a data:application/pdf;base64,… URI. Use a URL or data URI when this server runs remotely (Smithery, hosted gateways) where local paths do not exist. | |
| output_path | No | Path of a .pdf file to write the result to, inside the allowed directories (PDFOPS_ROOT, default the working directory); an existing file there is overwritten. Omit when running remotely: the PDF is then returned inline as an application/pdf resource for the client to save. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| bytes | Yes | Size of the produced PDF in bytes | |
| output_path | No | Absolute path written, when output_path was supplied | |
| resource_uri | No | pdfops:// uri of the inline application/pdf resource, when output_path was omitted |