Skip to main content
Version: 9.x

Split PDFs

Cuts a PDF into several, which come back in a ZIP.

POST/forms/pdf/split
filesfile[]required

The PDFs.

archivesfile[]

ZIP files Gotenberg unpacks: each entry counts as a file uploaded under files.

URLs Gotenberg downloads first, as if you had uploaded the files. Each entry takes a url, and optionally extraHttpHeaders.

everyinteger

Cuts every this many pages, at least 1. Set every or ranges, not both.

rangeslist

One PDF per entry, each a page selection such as 1-3 or 4,6.

A ZIP of the parts, or the one part as a PDF.

The route also takes the headers. An error answers a status and a message: see Errors.

Split every page​

curl \
--request POST http://localhost:3000/forms/pdf/split \
--form files=@report.pdf \
--form every=1 \
-o report.zip

The answer is a ZIP of report_0.pdf, report_1.pdf and report_2.pdf. every: 2 cuts every two pages instead, and every is at least 1. A split that yields one part answers that PDF, not a ZIP: every: 5 on this three-page report answers report_0.pdf.

Split by ranges​

ranges gives one PDF per entry, each a page selection:

curl \
--request POST http://localhost:3000/forms/pdf/split \
--form files=@report.pdf \
--form 'ranges=[
"1",
"2-3"
]' \
-o report.zip

Process each part​

The stages after a split run on each part. This one stamps both parts:

curl \
--request POST http://localhost:3000/forms/pdf/pipe \
--form files=@report.pdf \
--form 'stages=[
{ "op": "split", "ranges": [ "1", "2-3" ] },
{ "op": "stamp-text", "text": "DRAFT", "x": 36, "y": 36, "fontSize": 18 }
]' \
-o report.zip

In a list of stages​

The stage also runs in a list on /forms/pdf/pipe, and on the PDFs a Chromium or LibreOffice conversion makes, in its stages field:

curl \
--request POST http://localhost:3000/forms/pdf/pipe \
--form files=@report.pdf \
--form 'stages=[
{ "op": "split", "ranges": [ "1", "2-3" ] }
]' \
-o report.zip

To keep some pages in one PDF rather than cut it, select them.