Class 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 Detail

      • create

        public static Engine create​(java.lang.String name)
                             throws GenericException

        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 - 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 - The name argument is invalid.
        java.lang.IllegalArgumentException - if name is null
      • 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.IOException

        Close the engine

        Release all native resources associated with the OCR engine.
        Specified by:
        close in interface java.lang.AutoCloseable
        Throws:
        PdfToolsException - only explicitly stated in a superclass
        java.io.IOException