Skip to content

PDF Contains Text

Type: pdf-contains-text  ·  Package: PDF Activities v1.2.4  ·  Output: bool

Checks whether the PDF contains a text on any of its pages and returns true or false. Useful to classify documents quickly: is it an invoice? does it include a given clause? does it mention a customer?

Looks for text page by page, in the text extracted from each one (the same one PDF Get Text (Page) returns), and returns true as soon as it finds it, without reading the rest. By default the search is case-insensitive (caseSensitive = false). It doesn’t modify the file.

  • It is a literal text search, not a regular expression. For patterns, use PDF Get Text and regexMatch.
  • The search runs within each page: a text split between the end of one page and the start of the next is not found.
  • If a phrase isn’t found even though you see it in the PDF, check how it comes out in the extracted text: spaces and line breaks may not be the ones you see on screen.
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 bool: true if the text appears on any page, false otherwise. On a scanned PDF (no text layer) it returns false.

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.

Classify a PDF by its content:

PDF Contains Text path = filePath text = "ELECTRONIC INVOICE" → output: isInvoice
If condition = isInvoice
└─ then:
Move File source = filePath destination = pathJoin("C:/invoices", fileName(filePath))