Split
Cut a PDF into several files, every so many pages or by page ranges.
POST /v1/split cuts a document into several PDFs and answers with a ZIP holding them in order,
named part-1.pdf, part-2.pdf… (with leading zeros past nine, so they sort). Give one of:
| Field | Meaning |
|---|---|
every | A new file every so many pages: 1 for one file per page, 2 for pairs. |
ranges | JSON: a list of { "start", "end" }, counted from 0 and inclusive; -1 is the last page. Ranges may overlap or skip pages. |
At most 200 files per request. Any format convert accepts can be split; it is converted first.
Cost: 1 unit per file produced.
One file per page
curl https://api.nexpdf.dev/v1/split \
-H "Authorization: Bearer $NEXPDF_API_KEY" \
-F document=@statements.pdf \
-F every=1 \
-o pages.zipBy ranges
A packet whose first two pages are the cover letter and the rest the contract:
curl https://api.nexpdf.dev/v1/split \
-H "Authorization: Bearer $NEXPDF_API_KEY" \
-F document=@packet.pdf \
-F 'ranges=[{"start":0,"end":1}, {"start":2,"end":-1}]' \
-o parts.zipSplit after other steps
In a build, { "type": "split" } is an output like pdf, with every or ranges. The actions
run first, on the whole document, and the result is split. Here every payslip in a batch has its
social security numbers removed and becomes its own file:
curl https://api.nexpdf.dev/v1/build \
-H "Authorization: Bearer $NEXPDF_API_KEY" \
-F doc=@payslips.pdf \
-F 'instructions={
"parts": [
{
"file": "doc"
}
],
"actions": [
{
"type": "redact",
"query": "us-ssn",
"mode": "pattern"
}
],
"output": {
"type": "split",
"every": 1
}
}' \
-o payslips.zipTo take one range out of a document, without a ZIP, use a build with one part and its pages
instead (see Merge and pages).