PDF Get Words
PDF Get Words
Section titled “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.
How it works
Section titled “How it works”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.
Required parameters
Section titled “Required parameters”| Parameter | Editor | Description |
|---|---|---|
path | expression | PDF file path. |
Optional parameters
Section titled “Optional parameters”| Parameter | Editor | Description |
|---|---|---|
pages | expression | Pages to read: "all" (default) or a range such as "1-3,5,7-9". |
dpi | expression | When 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. |
Output
Section titled “Output”Returns a List of words. Each word has:
| Key | What it is |
|---|---|
text | The word. |
page | Page number (from 1). |
x | Distance from the left edge of the page. |
y | Distance from the top edge of the page. |
width | Width of the word. |
height | Height of the word. |
Example
Section titled “Example”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: imagesPDF Get Words path = = invoicePath dpi = 200 → output: wordsLog message = = "Words: " + count(words)Locate where a value appears on the page:
PDF Get Words path = = filePath pages = "1" → output: wordsFor Each collection = = words itemVariable = word └─ activities: If condition = = word["text"] == "TOTAL" └─ then: Log message = = "TOTAL is at x=" + word["x"] + " y=" + word["y"]Related activities
Section titled “Related activities”- PDF Get Text — the text without coordinates.
- PDF To Images — render the pages to images at the same DPI.
- OCR Get Lines — the same thing, but for scanned PDFs and images.