pdftools_sdk.ocr.engine

Classes

Engine(handle)

OCR engine

class pdftools_sdk.ocr.engine.Engine(handle)[source]

Bases: _NativeObject

OCR engine

An OCR engine is required for most OCR processing operations. Engines can be created using the static method pdftools_sdk.ocr.engine.Engine.create() .

OCR engines can be reused to process multiple files. However, one OCR engine can only be used to process one file at a time.

Note that some OCR engines must be disposed in the same thread where they have been created. Note that of some OCR engines only one instance can be created per process.

static create(name: str) Engine[source]

Create a new OCR engine

Optionally the name argument may be followed by “@” and engine creation parameters, e.g. “service@http://localhost:7982/”

Parameters:

name (str) – The engine name and optional creation parameters.

Returns:

The newly created engine instance.

Return type:

pdftools_sdk.ocr.engine.Engine

Raises:
property languages: str | None

The OCR language settings

Set the languages used for recognition to improve detection accuracy. Note that for some engines it is crucial to set the used languages correctly. For example, ABBYY FineReader will only detect characters used in the specified languages.

Multiple languages can be specified as a comma-separated list, e.g. “German,English”.

Default value: None (engine default)

Returns:

Optional[str]

property parameters: str | None

Engine-specific parameters

OCR engine-specific parameters can be set to optimize performance or activate optional recognition features.

Parameters are specified as semicolon-separated key=value pairs, e.g. “PredefinedProfile=Default;Profile=/path/to/profile.ini”. The available parameters depend on the OCR engine. Commonly supported parameters include: - “PredefinedProfile”: Name of a predefined recognition profile (default: “Default”). - “Profile”: Path to a custom profile file. Applied after the predefined profile.

Parameter keys are case-sensitive.

Default value: None

Returns:

Optional[str]