Class Engine
- java.lang.Object
-
- com.pdftools.internal.NativeBase
-
- com.pdftools.internal.NativeObject
-
- com.pdftools.ocr.Engine
-
- All Implemented Interfaces:
java.lang.AutoCloseable
public class Engine extends NativeObject implements java.lang.AutoCloseable
OCR engine
An OCR engine is required for most OCR processing operations. Engines can be created using the static method
create(java.lang.String).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.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Close the enginestatic Enginecreate(java.lang.String name)Create a new OCR enginejava.lang.StringgetLanguages()The OCR language settings (Getter)java.lang.StringgetParameters()Engine-specific parameters (Getter)voidsetLanguages(java.lang.String value)The OCR language settings (Setter)voidsetParameters(java.lang.String value)Engine-specific parameters (Setter)-
Methods inherited from class com.pdftools.internal.NativeObject
equals, hashCode
-
-
-
-
Method Detail
-
create
public static Engine create(java.lang.String name) throws GenericException
Create a new OCR engine
Optionally thenameargument may be followed by "@" and engine creation parameters, e.g. "service@http://localhost:7982/"- Parameters:
name- The engine name and optional creation parameters.- Returns:
- The newly created engine instance.
- Throws:
GenericException- The engine could not be created, e.g. because the engine is not available.java.lang.IllegalArgumentException- Thenameargument is invalid.java.lang.IllegalArgumentException- ifnameisnull
-
getLanguages
public java.lang.String getLanguages()
The OCR language settings (Getter)
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:
null(engine default)
-
setLanguages
public void setLanguages(java.lang.String value)
The OCR language settings (Setter)
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:
null(engine default)- Throws:
java.lang.IllegalArgumentException- The languages argument is invalid.
-
getParameters
public java.lang.String getParameters()
Engine-specific parameters (Getter)
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:
null
-
setParameters
public void setParameters(java.lang.String value)
Engine-specific parameters (Setter)
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:
null- Throws:
java.lang.IllegalArgumentException- The parameters argument is invalid.
-
close
public void close() throws PdfToolsException, java.io.IOExceptionClose the engine
Release all native resources associated with the OCR engine.- Specified by:
closein interfacejava.lang.AutoCloseable- Throws:
PdfToolsException- only explicitly stated in a superclassjava.io.IOException
-
-