Skip to content

PDF Search Text

Type: pdf-search-text  ·  Package: PDF Activities v1.2.4  ·  Output: List

Searches for a text in the PDF and returns the list of page numbers (from 1) where it appears. Useful to locate sections inside long documents before extracting or manipulating those pages.

Goes through every page looking for text in the text extracted from each one (the same one PDF Get Text (Page) returns) and returns the numbers of the pages where it finds it. By default it is case-insensitive. It doesn’t modify the file.

  • It is a literal text search, not a regular expression.
  • Each page counts once, even if the text appears several times on it.
  • A text split across two pages is not found.
ParameterTypeDefaultDescription
pathstring—Path of the PDF file.
textstring—Text to look for.
ParameterTypeDefaultDescription
caseSensitiveboolfalseCase-sensitive search. The Designer switch or an expression that returns true/false. Since 1.2.4. Any other value is an error.

Returns a List of int with the page numbers (from 1), in ascending order, e.g. [2, 5]. If the text doesn’t appear —or the PDF is scanned—, an empty list.

MessageCause and fix
File not found.The path doesn’t exist.
'caseSensitive' must be true or false. Received: ….The caseSensitive expression didn’t return a yes/no. Since 1.2.4.
'path' is required. / 'text' 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.

Find the pages of an annex and extract them into a separate PDF:

PDF Search Text path = filePath text = "ANNEX A" → output: pages
If condition = count(pages) > 0
└─ then:
PDF Extract Pages path = filePath pages = pages output = "C:/annexA.pdf"

The list goes as is to PDF Extract Pages or PDF Rotate (since version 1.2.4; before, you had to turn it into text with join(pages, ",")). To keep only the first page, use pages = pages[0].