# WordFinder Class

> A class used to extract words from a document.

- Product: Adobe PDF Library 21
- Language: Modern C++
- Version: 21.4.0
- HTML page: https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/WordFinder
- Version index: https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/llms.txt

```cpp
class WordFinder
```

**Namespace:** `datalogics_interface`

## Description

A class used to extract words from a document.

**Uses types:** [`Word`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/Word.md), [`WordFinderVersion`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/enum/WordFinderVersion.md)

## Constructors

### WordFinder

```cpp
datalogics_interface::WordFinder::WordFinder(Document &doc, WordFinderVersion version, const WordFinderConfig &config)
```

*constructor*

**Parameters**

- `doc` ([`Document &`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/Document.md)): document in which to find words
- `version` ([`WordFinderVersion`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/enum/WordFinderVersion.md)): algorithm version to use
- `config` ([`const WordFinderConfig &`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/WordFinderConfig.md)): configuration for this word finder

Construct a WordFinder with a specific configuration. Create a word finder

### WordFinder

```cpp
datalogics_interface::WordFinder::WordFinder(Document &doc, WordFinderVersion version=WordFinderVersion::Latest)
```

*constructor*

**Parameters**

- `doc` ([`Document &`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/Document.md)): document in which to find words
- `version` ([`WordFinderVersion`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/enum/WordFinderVersion.md)): algorithm version to use

Create a word finder

### WordFinder

```cpp
datalogics_interface::WordFinder::WordFinder(WordFinder &&) noexcept
```

*constructor*

**Parameters**

- (unnamed) ([`WordFinder &&`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/WordFinder.md))

### ~WordFinder

```cpp
datalogics_interface::WordFinder::~WordFinder()
```

*destructor*

## Methods

### enum_words

```cpp
bool datalogics_interface::WordFinder::enum_words(int page_num, WordCallback callback)
```

**Parameters**

- `page_num` (`int`): The page number from which to extract words. Pass AllPages to sequentially process all pages in the document.
- `callback` (`WordCallback`): A user-supplied callback to call once for each word found. Enumeration halts if wordProc returns false.

**Returns:** `bool`

true if enumeration was successfully completed, false if enumeration was terminated because wordProc returned false.

Extracts words, one at a time, from the specified page or the entire document. It calls a user-supplied procedure once for each word found.

Only words within or partially within the page's crop box (see Page::CropBox) are enumerated. Words outside the crop box are skipped.

Word objects passed to wordProc become invalid once the call to EnumWords returns, or if the page number changes between calls to the WordProc.

### get_visible_word_list

```cpp
std::vector< Word > datalogics_interface::WordFinder::get_visible_word_list(int page_num)
```

**Parameters**

- `page_num` (`int`): the page number for which to get the list of words.

**Returns:** [`std::vector< Word >`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/Word.md)

a list of x, y sorted words on the specified page.

Finds all Visible words on the specified page and returns a list containing the words. The words are sorted by their x- and y-coordinates on the page.

NOTE: Only words visible according to the Optional Content are returned.

### get_word_list

```cpp
std::vector< Word > datalogics_interface::WordFinder::get_word_list(int page_num)
```

**Parameters**

- `page_num` (`int`): the page number for which to get the list of words.

**Returns:** [`std::vector< Word >`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/Word.md)

a list of x, y sorted words on the specified page.

Finds all words on the specified page and returns a list containing the words. The words are sorted by their x- and y-coordinates on the page.

NOTE: All words found on the page are returned, even if they are currently invisible as specified by the Optional Content.

### operator=

```cpp
WordFinder & datalogics_interface::WordFinder::operator=(WordFinder &&) noexcept
```

**Parameters**

- (unnamed) ([`WordFinder &&`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/WordFinder.md))

**Returns:** [`WordFinder &`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/WordFinder.md)
