Extract pages from a PDF by API: page list syntax
Pull selected pages out of a PDF with one API call. The page list syntax with ranges, odd and even, and negative numbers, plus the result, errors and cost.
The PDF Extract Pages API makes a new PDF with only the pages you list. It is the right call when you know which pages you want and want them in their original order.
curl https://api.justapi.tech/v1/pdf/extract-pages \
-H "Authorization: Bearer ak_live_..." \
-H "Content-Type: application/json" \
-d '{"source": {"url": "https://files.example.com/annual-report.pdf"}, "options": {"pages": "1,12-18,-1"}}'
Page list syntax
The same syntax works for every JustAPI page tool:
| You write | You get |
|---|---|
7 |
page 7 |
1-3 |
pages 1, 2 and 3 |
12- |
page 12 to the end |
-1 |
the last page |
-3--1 |
the last three pages |
odd / even |
every odd or even page |
[1, 2, 5] |
a JSON list works too |
Combine parts with commas: 1,12-18,-1.
Order and duplicates
Extract keeps the pages in document order and ignores duplicates. 5,1,5 gives pages 1 and 5. If you need a different order or a page twice, use the PDF Organize API instead, which follows your list exactly.
What is kept
Each page is copied with its content, fonts and images. Links inside the page keep working. Document-level bookmarks that point at pages you did not keep are not carried over.
Errors and cost
pagesis required. Leaving it out, or asking for every page, is aninvalid_request.- A page past the end fails with
invalid_requestand names the page. - A signed PDF fails with
signed_pdf, and an encrypted one withencrypted_pdf.
None of these are charged. A successful extraction costs $0.005 at the first volume tier.
Several sections at once
If you need three sections as three files, one split call with ranges returns them together in a ZIP. Extract is for one new file.
Try a page list on your own file with the free page extractor.