Skip to content

PDF Get Words

Type: pdf-get-words  ·  Package: PDF Activities v1.1.0  ·  Output: List

Extracts every word of the PDF along with its page and its bounding box (position and size). It is the “with position” version of PDF Get Text: instead of a block of text, it tells you where each word sits on the page.

It goes through the requested pages and returns a flat list of words (not grouped by page or by line): each item carries its own page number.

Coordinates use a top-left origin — the same one images and OCR use. That way the words this activity returns and the lines OCR Get Lines returns speak the same language, and you can locate a value on the page no matter where it came from.

By default coordinates come back in PDF points (a point is 1/72 of an inch). If you set dpi, they come back in pixels for a render at that resolution: this makes them line up with the files produced by PDF To Images at the same dpi, so you can crop or draw on the image using these coordinates directly.

ParameterEditorDescription
pathexpressionPDF file path.
ParameterEditorDescription
pagesexpressionPages to read: "all" (default) or a range such as "1-3,5,7-9".
dpiexpressionWhen set, coordinates are returned in pixels for a render at this resolution (they line up with PDF To Images at the same DPI). When omitted, in PDF points. Between 36 and 1200.

Returns a List of words. Each word has:

KeyWhat it is
textThe word.
pagePage number (from 1).
xDistance from the left edge of the page.
yDistance from the top edge of the page.
widthWidth of the word.
heightHeight of the word.

Render the PDF and extract the words with coordinates that match the images:

PDF To Images path = = invoicePath outputDir = "C:/temp/pages" dpi = 200 → output: images
PDF Get Words path = = invoicePath dpi = 200 → output: words
Log message = = "Words: " + count(words)

Locate where a value appears on the page:

PDF Get Words path = = filePath pages = "1" → output: words
For Each collection = = words itemVariable = word
└─ activities:
If condition = = word["text"] == "TOTAL"
└─ then:
Log message = = "TOTAL is at x=" + word["x"] + " y=" + word["y"]