Foxit PDF SDK

Public Member Functions | Static Public Member Functions | List of all members
com.foxit.sdk.addon.ocr.OCREngine Class Reference

## Public Member Functions
synchronized void | delete ()
| Clean up related C++ resources immediately. More...

## Static Public Member Functions
static int | initialize (String ocr_resource_path)
| Initialize OCR engine. More...
static int | initialize (String ocr_resource_path, boolean is_shared_cpu_cores_mode)
| Initialize OCR engine. More...
static void | release ()
| Release OCR engine. More...
static void | setLanguages (String languages) throws com.foxit.sdk.PDFException
| Set the name of languages which would be included in the language database for doing OCR. More...
static void | setLogFile (String log_file_path) throws com.foxit.sdk.PDFException
| Set log file for OCR engine. More...
static void | setOCRCallback (OCRCallback callback) throws com.foxit.sdk.PDFException
| Set the callback object used to cancel OCR progress. More...

## Detailed Description

OCR add-on module can be used to convert text content of image to searchable text or editable text in a PDF page or a PDF document. Before using OCR module, user should first prepare OCR resource folder as described in "Foxit PDF SDK Developer Guide.pdf" document. Before initializing OCR engine and using any classes or methods in this module, please ensure Foxit PDF SDK has been initialized successfully by function common.Library.initialize with a key including "OCR" module.
Currently, OCR module only supports Windows and Linux64 system.

See also
  com.foxit.sdk.common.Library

## Member Function Documentation

## ◆ delete()

synchronized void com.foxit.sdk.addon.ocr.OCREngine.delete | ( |  | ) |

Clean up related C++ resources immediately.

Returns
  None.

Note
  Once this function is called, current object cannot be used anymore.

## ◆ initialize() [1/2]

static int com.foxit.sdk.addon.ocr.OCREngine.initialize | ( | String | ocr_resource_path | ) |
| static

Initialize OCR engine.

This should be called successfully before any other methods in OCR add-on module.

Parameters

  [in] | ocr_resource_path | File path of ocr resource folder. It should not be an empty string. Please refer to "Foxit PDF SDK Developer Guide.pdf" document for more details.

Note
  If module "OCR" is not defined in the license information which is used in function common.Library.initialize , that means user has no right in using OCR related functions and this constructor will throw exception com.foxit.sdk.common.Constants.e_ErrNoOCRModuleRight .

Returns
  com.foxit.sdk.common.Constants.e_ErrSuccess means success.
  com.foxit.sdk.common.Constants.e_ErrNoOCRModuleRight means Foxit PDF SDK has not been initialized with a key including "OCR" module.
  com.foxit.sdk.common.Constants.e_ErrParam means parameter ocrt_resource_path is an empty string.
  For more information about error code values, please refer to values starting from com.foxit.sdk.common.Constants.e_ErrSuccess .

## ◆ initialize() [2/2]

static int com.foxit.sdk.addon.ocr.OCREngine.initialize | ( | String | ocr_resource_path,
|  | boolean | is_shared_cpu_cores_mode
| ) |  |
| static

Initialize OCR engine.

This should be called successfully before any other methods in OCR add-on module.

Parameters

  [in] | ocr_resource_path | File path of ocr resource folder. It should not be an empty string. Please refer to "Foxit PDF SDK Developer Guide.pdf" document for more details.
  [in] | is_shared_cpu_cores_mode | A boolean value specifies whether the CPU cores should be used in shared mode. There are two modes of CPU cores usage: separate and shared. In separate mode OCR Engine uses no more processes than it is allowed by the license. In shared mode any number of processes can be run. true means the CPU cores should be used in shared mode, while false means not. In muti-process mode, it is strongly recommended to set this parameter to true, such as calling the function OCR.oCRPDFDocuments . In single-process mode, this parameter should be set to false. Default value: false.

Note
  If module "OCR" is not defined in the license information which is used in function common.Library.initialize , that means user has no right in using OCR related functions and this constructor will throw exception com.foxit.sdk.common.Constants.e_ErrNoOCRModuleRight .

Returns
  com.foxit.sdk.common.Constants.e_ErrSuccess means success.
  com.foxit.sdk.common.Constants.e_ErrNoOCRModuleRight means Foxit PDF SDK has not been initialized with a key including "OCR" module.
  com.foxit.sdk.common.Constants.e_ErrParam means parameter ocrt_resource_path is an empty string.
  For more information about error code values, please refer to values starting from com.foxit.sdk.common.Constants.e_ErrSuccess .

## ◆ release()

static void com.foxit.sdk.addon.ocr.OCREngine.release | ( |  | ) |
| static

Release OCR engine.

This function can be called to release OCR engine when no need to use it any more before Foxit PDF SDK is released.

Returns
  None.

## ◆ setLanguages()

static void com.foxit.sdk.addon.ocr.OCREngine.setLanguages | ( | String | languages | ) | throws com.foxit.sdk.PDFException
| static

Set the name of languages which would be included in the language database for doing OCR.

Current supported languages:

- When CJK language resources are used, support Chinese-Simplified, Chinese-Traditional, Japanese, Korean.

- When other language resources are used, support Basque, Bulgarian, Catalan, Croatian, Czech, Danish, Dutch, English , Estonian, Faeroese, Finnish, French, Galician, German, Greek, Hebrew, Hungarian, Icelandic, Italian, Latvian(Lettish), Lithuanian, Macedonian, Maltese, Norwegian, Polish, Portuguese, Romanian, Russian, Serbian, Slovak, Slovenian, Spanish, Swedish, Thai, Turkish, Ukrainian, Arabic.

If no any language is set by this function, Foxit PDF SDK will use "English" by default.

Parameters

  [in] | languages | Language names. This should not be an empty string. This can contain one language name or several language names separated with commas. For example, "English" means English only, and "English,French" means English and French only.

Returns
  None.

## ◆ setLogFile()

static void com.foxit.sdk.addon.ocr.OCREngine.setLogFile | ( | String | log_file_path | ) | throws com.foxit.sdk.PDFException
| static

Set log file for OCR engine.

This function is to set the log file for OCR engine, not for Foxit PDF SDK. If user wants to set log file for Foxit PDF SDK, please refer to function common.Library.setLogFile .

Parameters

  [in] | log_file_path | A log file path. If this is an empty string, that means stop the log for OCR engine.

Returns
  None.

## ◆ setOCRCallback()

static void com.foxit.sdk.addon.ocr.OCREngine.setOCRCallback | ( | OCRCallback | callback | ) | throws com.foxit.sdk.PDFException
| static

Set the callback object used to cancel OCR progress.

Parameters

  [in] | callback | A customized ocr callback which is implemented based on callback class OCRCallback . null means not use any ocr callback object. User should ensure all the callback functions have been implemented in application level.

Returns
  None.