PDF Search Text
PDF Search Text
Section titled “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.
How it works
Section titled “How it works”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.
Required parameters
Section titled “Required parameters”| Parameter | Type | Default | Description |
|---|---|---|---|
path | string | — | Path of the PDF file. |
text | string | — | Text to look for. |
Optional parameters
Section titled “Optional parameters”| Parameter | Type | Default | Description |
|---|---|---|---|
caseSensitive | bool | false | Case-sensitive search. The Designer switch or an expression that returns true/false. Since 1.2.4. Any other value is an error. |
Output
Section titled “Output”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.
Common errors
Section titled “Common errors”| Message | Cause 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 file | Password-protected or damaged PDF. See Protected and damaged PDFs. |
Example
Section titled “Example”Find the pages of an annex and extract them into a separate PDF:
PDF Search Text path = filePath text = "ANNEX A" → output: pagesIf 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].
Related activities
Section titled “Related activities”- PDF Contains Text — just find out whether it appears (yes/no).
- PDF Extract Pages — extract the pages found.