Remove pages from PDF
The "Remove pages from PDF" service task removes specific pages from a PDF file. This can be used to strip cover sheets, blank pages or unnecessary appendices before further processing.
Input parameters
The task expects the following fields:
{
"pdf": {
"referenceId": "...",
"filename": "contract.pdf",
"contentType": "application/pdf"
},
"pages": [1, 5, 8]
}
Explanation:
pdf: File reference of the PDF from which pages should be removed (required).pages: Array of page numbers to remove (required). Page numbers are 1-based – page 1 is the first page of the document.
Output
The task returns a file reference to the new PDF (without the removed pages).
{
"referenceId": "...",
"filename": "contract.pdf",
"contentType": "application/pdf",
"removedCount": 3,
"remainingCount": 9
}
Explanation:
referenceId: File reference of the new PDF.filename: Filename (carried over from the original).contentType: MIME type of the file.removedCount: Number of pages actually removed.remainingCount: Number of remaining pages.
JSONata examples
Remove first page (cover sheet):
{
"pdf": $.document,
"pages": [1]
}
Remove first and last page:
{
"pdf": $.document,
"pages": [1, $.metadata.pageCount]
}
Notes
- Page numbers that do not exist in the document (e.g. page 20 in a 10-page PDF) are silently ignored.
- At least one page must remain in the document – otherwise an error is returned.
- The original order of the remaining pages is preserved.
Tip
Combine this with the "Read PDF metadata" service to determine the page count in advance. This allows dynamically removing the last page without hard-coding the total page count in the process.