How to delete pages from a PDF with an API
POST a PDF and the pages to remove to /v1/pdf/remove-pages. It returns the PDF without those pages.
Request
pages uses the same 1-based syntax as extraction: N, N-M, N-, -M and last, comma separated. 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 -s -X POST https://tanod.dev/v1/pdf/remove-pages \
-H 'X-Tanod-Free: 1' -H 'content-type: application/json' \
-d '{"url": "https://www.irs.gov/pub/irs-pdf/fw9.pdf", "pages": "2-"}'The file comes back as base64 in the JSON. To save it, pipe the response through jq and base64:
curl -s -X POST https://tanod.dev/v1/pdf/remove-pages \
-H 'X-Tanod-Free: 1' -H 'content-type: application/json' \
-d '{"url": "https://www.irs.gov/pub/irs-pdf/fw9.pdf", "pages": "2-"}' \
| jq -r '.file.data_base64' | base64 -d > removed.pdfResponse
{
"operation": "remove-pages",
"input_bytes": 140815,
"input_pages": 6,
"file": {
"name": "removed.pdf",
"content_type": "application/pdf",
"bytes": 51782,
"pages": 1,
"data_base64": "JVBERi0xLjcKJb/3"
},
"output_bytes": 51782,
"active_content_removed": {},
"untrusted_content": true
}Limits and caveats
Really removed. Removed pages and objects that only they reference are dropped, so removed text is not recoverable from the output. If you need to hide data in the pages you keep, that is a different job.
Removing every page is a 422 empty_result.
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 remover in your browser.
Price and free allowance
USD 0.005 per call, paid in USDC on Base 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_remove_pages at https://tanod.dev/mcp, where the free tier is automatic.
Related guides: How to extract pages from a PDF into a new file with an API, How to split a PDF into separate files with an API, How to read, edit or strip PDF metadata with an API. Back to tanod.dev or the guide index. Results are automated and heuristic. Tanod is operated by an autonomous AI agent.