How to extract pages from a PDF into a new file with an API

Updated 2026-10-12

Use when only certain pages of a PDF are needed as a new, smaller PDF. Add output=url for a 24 h link.

From an MCP client, add https://tanod.dev/mcp and call pdf_extract_pages; its free daily calls are applied automatically, no key or signup.

POST a PDF and a page selection to /v1/pdf/extract-pages. It returns a new PDF containing only those pages, in the order you list them.

Request

pages is 1-based and comma separated: N, N-M, N- (to the end), -M and last. Repeats are allowed. Input is a PDF URL (up to 20 MB) or pdf_base64 (up to 10 MB decoded). Output over 15 MB is a 413 output_too_large and is not charged.

curl, using the free tier
curl -s -X POST https://tanod.dev/v1/pdf/extract-pages \
  -H 'X-Tanod-Free: 1' -H 'content-type: application/json' \
  -d '{"url": "https://www.irs.gov/pub/irs-pdf/fw9.pdf", "pages": "1-2,last"}'

The file comes back as base64 in the JSON. To save it, pipe the response through jq and base64:

save the result to a file
curl -s -X POST https://tanod.dev/v1/pdf/extract-pages \
  -H 'X-Tanod-Free: 1' -H 'content-type: application/json' \
  -d '{"url": "https://www.irs.gov/pub/irs-pdf/fw9.pdf", "pages": "1-2,last"}' \
  | jq -r '.file.data_base64' | base64 -d > extracted.pdf

Response

Response (example from the API spec, trimmed)
{
  "operation": "extract-pages",
  "input_bytes": 140815,
  "input_pages": 6,
  "file": {
    "name": "extracted.pdf",
    "content_type": "application/pdf",
    "bytes": 58827,
    "pages": 3,
    "data_base64": "JVBERi0xLjcKJb/3"
  },
  "output_bytes": 58827,
  "active_content_removed": {},
  "untrusted_content": true
}

Limits and caveats

Strict ranges. An out-of-range or reversed part is a 422 page_out_of_range; it is never clamped.

Unselected pages are gone. The pages and the objects only they used are removed, with no orphaned content left in the file.

Active content is stripped. JavaScript, launch and submit actions, embedded files and XFA forms are always removed from the output and counted in active_content_removed. Features that depend on them, such as XFA forms or scripted buttons, will not work in the output.

Encrypted input is a 422 pdf_encrypted; unlock it first.

Doing this by hand? Use the free PDF page extractor in your browser.

Download link. Add "output": "url" to the request and the file is stored for 24 hours and returned as a link (url, expires_at, sha256) instead of base64, which keeps it out of your context window. The price is the same. How the links work.

Price and free allowance

USD 0.005 per call, paid in USDC on Base, Polygon, Solana, BNB Chain or Arbitrum with x402. 3 free calls per IP per UTC day with the header X-Tanod-Free: 1. The pool is shared by merge, split, extract and remove pages, rotate, watermark, page numbers, protect, unlock and metadata. MCP tool: pdf_extract_pages at https://tanod.dev/mcp, where the free tier is automatic.

All endpoints →

Use it from Claude without writing code: in claude.ai or Claude Desktop, add https://tanod.dev/mcp/docs?via=extract-pdf-pages-api as a custom connector (steps), then ask in plain words, for example "Pull pages 3 to 5 out of this PDF into a new file." The free daily allowance is applied automatically over MCP. Beyond it a call needs an x402 payment, which these clients can make.

Related guides: How to delete pages from a PDF with an API, How to split a PDF into separate files with an API, How to merge PDF files with an API. Back to tanod.dev or the guide index. Results are automated and heuristic.