Split a PDF by API: single pages, chunks or ranges
How to split a PDF with one API call: one file per page, every N pages, or named ranges. When you get a PDF back, when you get a ZIP, and what a failure costs.
Splitting a PDF sounds like one job, but workflows ask for three different ones. A scanning app wants one file per page. A batch of invoices printed back to back wants a new file every two pages. A contract pack wants the main agreement, the annex and the signature page as separate files. The PDF Split API handles all three with one endpoint and a mode option.
The three modes
each: one PDF per page. A 12-page file gives 12 PDFs.every: a new PDF every N pages. Withevery: 2, a 12-page file gives 6 PDFs of 2 pages.ranges: one PDF per range you list, like["1-3", "4-10", "11-"].
If you send ranges and leave out mode, the API assumes you meant ranges.
curl https://api.justapi.tech/v1/pdf/split \
-H "Authorization: Bearer ak_live_..." \
-H "Content-Type: application/json" \
-d '{"source": {"url": "https://files.example.com/contract-pack.pdf"}, "options": {"mode": "ranges", "ranges": ["1-8", "9-11", "-1"]}}'
Range syntax is the same across every page tool: 5- means page 5 to the end, and negative numbers count from the end, so -1 is the last page.
A PDF or a ZIP
When the rule produces one part, you get that PDF back directly. When it produces more than one, you get a ZIP with the parts named part-1.pdf, part-2.pdf and so on. Set filename_prefix to name them after the source, for example invoice for invoice-1.pdf.
Read result.content_type rather than guessing: it is application/pdf for one part and application/zip for several. stats.files says how many parts there are. If you need each part as its own file in your storage, unzip the result or call split with a single range per call.
Nothing is re-encoded
Each page is copied into its part with its fonts, images and text layer as they are. Split does not compress, re-render or change anything inside the page. The parts together are usually a little larger than the source, because shared fonts are copied into each part that uses them.
Limits and failures
A split can make up to 500 parts. A request that would make more is refused before any work, with invalid_request, and costs nothing. An encrypted PDF fails with encrypted_pdf; unlock it first with the PDF Unlock API. A range that points past the last page is an invalid_request that names the page.
Every failure is free. The call is synchronous and all or nothing: either you get the parts, or you get an error and no charge.
What it costs
One price per call, whatever the size: $0.005 at the first volume tier, less above 1,000 calls a month. Splitting a 300-page file into 300 PDFs costs the same as splitting a 2-page file into two. See the pricing page for the tiers.
Try it on one file first
The free PDF splitter runs the same job in the browser for files up to 5 MB, five times a day. Use it to check your ranges before you wire the API into a workflow. The full option list is in the PDF Split API reference.