PDF Extract Pages
PDF Extract Pages
Section titled “PDF Extract Pages”Type: pdf-extract-pages · Package: PDF Activities v1.2.4 · Output: string
Extracts specific pages from a PDF and saves them in a new file. Useful to keep only what matters: separate an annex, drop blank pages, trim a document.
How it works
Section titled “How it works”Takes the pages listed in pages from the source PDF and creates a new PDF at output. Returns the path of the file created. The original stays intact.
- Pages are given as a text range (
"1-3,5,7-9"), a number or a list of numbers; the list returned by PDF Search Text works as is. Since 1.2.4. - Pages are copied in ascending order and without repeats:
"5,1"produces a PDF with page 1 and then page 5. To reorder, extract separately and combine with PDF Merge in the order you want. "all"is not accepted here: to copy the whole document, use a full range ("1-" + total).- It creates the
outputfolder if it doesn’t exist and overwrites the file if it already exists.
Required parameters
Section titled “Required parameters”| Parameter | Type | Default | Description |
|---|---|---|---|
path | string | — | Path of the source PDF. |
pages | string | List | — | Pages to extract: text range ("1-3,5"), a number or a list of numbers (pages, new[] { 1, 3 }). A list item that isn’t an integer is an error. |
output | string | — | Path of the resulting PDF. |
Optional parameters
Section titled “Optional parameters”None.
Output
Section titled “Output”Returns a string with the path of the PDF created (the same as output).
Common errors
Section titled “Common errors”| Message | Cause and fix |
|---|---|
'pages' must contain whole page numbers; '…' is not one. | The list holds something that isn’t a whole page number (a text, a decimal). Since 1.2.4. |
No valid pages were specified. | pages holds no valid number (e.g. "all", an empty text or an empty list). |
Page(s) out of range: …. The document has … pages. | Some requested page doesn’t exist. Get the total first with PDF Get Page Count. |
File not found. | The path doesn’t exist. |
'path' is required. / 'pages' is required. / 'output' is required. | The parameter was left empty or its expression returned null. |
| PDF library error when opening the file | Password-protected or damaged PDF. See Protected and damaged PDFs. |
Example
Section titled “Example”PDF Extract Pages path = filePath pages = "1-3,5" output = "C:/summary.pdf" → output: summaryLog message = "Summary created at " + summaryRemove the cover (every page except the first):
PDF Get Page Count path = filePath → output: totalPDF Extract Pages path = filePath pages = "2-" + total output = "C:/no-cover.pdf"Related activities
Section titled “Related activities”- PDF Split — split every page into separate files.
- PDF Merge — combine several PDFs.
- PDF Search Text — find the pages to extract.