# OCREngine Class

> Represents an OCR Engine and its configuration.

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

```cpp
class OCREngine
```

**Namespace:** `datalogics_interface`

## Description

Represents an OCR Engine and its configuration.

Create an OCREngine object once, and reuse it to convert multiple images to Form objects to avoid repeating the sometimes expensive initialization of the engine. The configuration of the engine can't be changed after it's created; if you need to do that, create another OCREngine object.

**Uses types:** [`Form`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/Form.md), [`OCRLanguage`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/enum/OCRLanguage.md), [`OCRMissingFontStrategy`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/enum/OCRMissingFontStrategy.md), [`OCRParams`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/OCRParams.md)

## Constructors

### OCREngine

```cpp
datalogics_interface::OCREngine::OCREngine()
```

*constructor*

Create an OCR engine with default parameters.

### OCREngine

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

*constructor*

**Parameters**

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

### OCREngine

```cpp
datalogics_interface::OCREngine::OCREngine(OCRParams params)
```

*constructor*

**Parameters**

- `params` ([`OCRParams`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/OCRParams.md)): the configuration to use

Create an OCR engine with a specified configuration.

### ~OCREngine

```cpp
datalogics_interface::OCREngine::~OCREngine()
```

*destructor*

## Methods

### get_available_languages

```cpp
std::vector< OCRLanguage > datalogics_interface::OCREngine::get_available_languages() const
```

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

the list of languages supported, or null if that list can't be determined.

Get a list of languages this OCREngine can use.

### is_language_available

```cpp
bool datalogics_interface::OCREngine::is_language_available(OCRLanguage language) const
```

**Parameters**

- `language` ([`OCRLanguage`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/enum/OCRLanguage.md)): the language to check

**Returns:** `bool`

true if the language is available, false otherwise

Query if a language for OCR is available for use.

### operator=

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

**Parameters**

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

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

### place_text_under

```cpp
std::unique_ptr< Form > datalogics_interface::OCREngine::place_text_under(Image &image) const
```

**Parameters**

- `image` ([`Image &`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/Image.md)): The image in which to recognize text.

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

a Form element containing the image with text underneath.

Recognize text in the image, returning a form element with the image and the text underneath.

Recognize text in the image, returning a form with the image and text underneath.

Run the image through an OCR engine. Creates a Form element containing the image, and additional text underneath. The Form element has a transformation matrix which makes it directly substitutable for the image in a Content stream.

This method may throw an exception if it can't find a font that will represent all the characters in a word. See the candidateFontNames on OCRParams to supply more fonts.

### place_text_under

```cpp
std::unique_ptr< Form > datalogics_interface::OCREngine::place_text_under(Image &image, Document &document) const
```

**Parameters**

- `image` ([`Image &`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/Image.md)): The image in which to recognize text.
- `document` ([`Document &`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/Document.md))

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

a Form element containing the image with text underneath.

Recognize text in the image, returning a form element with the image and the text underneath.

Recognize text in the image within a destination document.

Run the image through an OCR engine. Creates a Form element containing the image, and additional text underneath. The Form element has a transformation matrix which makes it directly substitutable for the image in a Content stream.

This method may throw an exception if it can't find a font that will represent all the characters in a word. See the candidateFontNames on OCRParams to supply more fonts.

### place_text_under

```cpp
std::unique_ptr< Form > datalogics_interface::OCREngine::place_text_under(Image &image, Document &document, double resolution) const
```

**Parameters**

- `image` ([`Image &`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/Image.md)): The image in which to recognize text.
- `document` ([`Document &`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/Document.md))
- `resolution` (`double`)

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

a Form element containing the image with text underneath.

Recognize text in the image, returning a form element with the image and the text underneath.

Recognize text with a known image resolution.

Run the image through an OCR engine. Creates a Form element containing the image, and additional text underneath. The Form element has a transformation matrix which makes it directly substitutable for the image in a Content stream.

This method may throw an exception if it can't find a font that will represent all the characters in a word. See the candidateFontNames on OCRParams to supply more fonts.

### place_text_under

```cpp
std::unique_ptr< Form > datalogics_interface::OCREngine::place_text_under(Image &image, Document &document, double resolution, OCRMissingFontStrategy strategy) const
```

**Parameters**

- `image` ([`Image &`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/Image.md)): The image in which to recognize text.
- `document` ([`Document &`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/Document.md))
- `resolution` (`double`)
- `strategy` ([`OCRMissingFontStrategy`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/enum/OCRMissingFontStrategy.md))

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

a Form element containing the image with text underneath.

Recognize text in the image, returning a form element with the image and the text underneath.

Recognize text with known resolution and missing font strategy.

Run the image through an OCR engine. Creates a Form element containing the image, and additional text underneath. The Form element has a transformation matrix which makes it directly substitutable for the image in a Content stream.

This method may throw an exception if it can't find a font that will represent all the characters in a word. See the candidateFontNames on OCRParams to supply more fonts.

### place_text_under

```cpp
std::unique_ptr< Form > datalogics_interface::OCREngine::place_text_under(Image &image, Document &document, OCRMissingFontStrategy strategy) const
```

**Parameters**

- `image` ([`Image &`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/Image.md)): The image in which to recognize text.
- `document` ([`Document &`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/Document.md))
- `strategy` ([`OCRMissingFontStrategy`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/enum/OCRMissingFontStrategy.md))

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

a Form element containing the image with text underneath.

Recognize text in the image, returning a form element with the image and the text underneath.

Recognize text with a missing font strategy.

Run the image through an OCR engine. Creates a Form element containing the image, and additional text underneath. The Form element has a transformation matrix which makes it directly substitutable for the image in a Content stream.

This method may throw an exception if it can't find a font that will represent all the characters in a word. See the candidateFontNames on OCRParams to supply more fonts.
