Skip to content

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.

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 output folder if it doesn’t exist and overwrites the file if it already exists.
ParameterTypeDefaultDescription
pathstring—Path of the source PDF.
pagesstring | 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.
outputstring—Path of the resulting PDF.

None.

Returns a string with the path of the PDF created (the same as output).

MessageCause 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 filePassword-protected or damaged PDF. See Protected and damaged PDFs.
PDF Extract Pages path = filePath pages = "1-3,5" output = "C:/summary.pdf" → output: summary
Log message = "Summary created at " + summary

Remove the cover (every page except the first):

PDF Get Page Count path = filePath → output: total
PDF Extract Pages path = filePath pages = "2-" + total output = "C:/no-cover.pdf"