Split PDF
The "Split PDF" service task splits a PDF file into multiple separate documents. This can be used to break up multi-page PDFs into individual documents or extract specific page ranges.
Input parameters
The task expects the following fields:
{
"pdf": {
"referenceId": "...",
"filename": "batch-invoice.pdf",
"contentType": "application/pdf"
},
"splits": {
"0": { "from": 1, "to": 3 },
"1": { "from": 4, "to": 6 }
},
"filenamePattern": "{name}_part-{n}"
}
Explanation:
pdf: File reference of the PDF to be split (required).splits: An object with numbered entries, each defining a page range (optional).from: First page of the range (1-based). If omitted, the range starts at page 1.to: Last page of the range (1-based, inclusive). If omitted, the range extends to the last page.filename: Optional custom filename for this part.
filenamePattern: Pattern for naming the output files (optional). Available placeholders:{name}– Original filename (without.pdf){n}– Sequential part number (1, 2, 3, ...)- The
.pdfextension is added automatically if missing.
Without splits
If splits is not specified, each page is extracted as a separate PDF file.
Output
The task returns an array of file references – one per output document.
{
"files": [
{
"referenceId": "...",
"filename": "batch-invoice_part-1.pdf",
"contentType": "application/pdf"
},
{
"referenceId": "...",
"filename": "batch-invoice_part-2.pdf",
"contentType": "application/pdf"
}
],
"count": 2
}
Explanation:
files: Array of file references for all output documents.count: Number of PDF files created.
JSONata examples
Extract each page individually (simplest case):
{
"pdf": $.document
}
Split into specific page ranges:
{
"pdf": $.document,
"splits": {
"0": { "from": 1, "to": 2 },
"1": { "from": 3 }
}
}
Notes
- Page numbers are 1-based and inclusive:
{ "from": 1, "to": 3 }produces a PDF containing pages 1, 2 and 3. - Invalid page numbers (e.g. higher than the total page count) are automatically clamped to the valid range.
- Overlapping splits produce documents with duplicate pages – this is intentional and can be used to create copies.
Tip
Combine this with the "Read PDF metadata" service to determine the page count in advance, then use it as a gateway condition – for example to only split PDFs with more than 10 pages.