L_Doc2StartUp

#include "ltdoc2.h"

L_LTDOC2_API L_INT EXT_FUNCTION L_Doc2StartUp(phDoc, pszEnginePath, bUseThunk)

L_HDOC2 * phDoc;

/* pointer to document handle to be updated */

L_TCHAR * pszEnginePath;

/* OCR engine location */

L_BOOL bUseThunk;

/* Flag to determine to use thunk or not */

Starts the OCR document engine and initializes the handle.

Parameter

Description

phDoc

Pointer to a document handle to be updated with the initialized OCR document handle. Use this handle in other OCR functions.

pszEnginePath

Character string that contains the path to the OCR engine files. Pass NULL to use the default path where the LEAD setup has installed the OCR engine files.

bUseThunk

Flag to determine to use thunk or not, possible values as follows:

 

Value

Meaning

 

TRUE

Use thunk in starting the OCR engine.

 

FALSE

Don't use thunk in starting the OCR engine.

Returns

SUCCESS

The function was successful.

< 1

An error occurred. Refer to Return Codes.

Comments

The L_Doc2StartUp function must be called before calling any other LEADTOOLS OCR document toolkit functions.

The user must unlock the OCR document toolkit using the L_SetLicenseFile function. If the OCR document toolkit is locked then the L_Doc2StartUp function will fail and will not initialize the OCR document toolkit.

This function will load and start the OCR document engine. When the handle to the OCR document is no longer needed, it should be freed by calling the L_Doc2ShutDown function. For every call to L_Doc2StartUp there must be an associated call to L_Doc2ShutDown function.

After starting up the engine, you should create setting collection by calling the L_Doc2CreateSettingsCollection function, and activate it by calling the L_Doc2SetActiveSettingsCollection function.

In x64 platform, the function will ignore the bUseThunk parameter value and will startup the OCR engine with thunk (this function will consider bUseThunk equals to TRUE in x64 platform)

OCR can be run in thread safe when passing TRUE to bUseThunk parameter, otherwise it will not be thread safe.

Required DLLs and Libraries

LTDOC2

For a listing of the exact DLLs and Libraries needed, based on the toolkit version, refer to Files To Be Included With Your Application.

See Also

Functions:

L_Doc2ShutDown, L_Doc2CreateSettingsCollection, L_Doc2DeleteSettingsCollection, L_Doc2SetActiveSettingsCollection

Topics:

OCR Functions: Starting and Shutting Down

 

Starting and Shutting Down the Engine

 

Unlocking Support

 

Using the THUNK Utility for COR

Example

L_LTDOC2TEX_API  L_INT Doc2StartUpExample(L_TCHAR* pszSettingFile)
{
   L_INT nRet ;
   L_HDOC2 hDoc = NULL;

   nRet = L_Doc2StartUp(&hDoc, NULL, FALSE);
   if (nRet != SUCCESS)
      return nRet;

   L_INT nSId;
   L_Doc2CreateSettingsCollection(hDoc, -1, &nSId);
   L_Doc2SetActiveSettingsCollection(hDoc, nSId);

   nRet = L_Doc2LoadSettings(hDoc, pszSettingFile);
   if(nRet != SUCCESS)
      return nRet;

   DOC2_FILLMETHOD fm;
   nRet = L_Doc2GetFillMethod(hDoc, &fm);
   if (nRet == SUCCESS)
   {
      if (fm != DOC2_FILL_HANDPRINT)
      {
         nRet = L_Doc2SetFillMethod(hDoc, DOC2_FILL_HANDPRINT);
         if(nRet != SUCCESS)
            return nRet;
      }
   }
   else
   {
      return nRet;
   }

   nRet = L_Doc2SaveSettings (hDoc, pszSettingFile);
   if (nRet == SUCCESS)
      MessageBox(NULL, TEXT("The engine saved the updated settings to a file."), TEXT("Notice!"), MB_OK);
   else
   {
      MessageBox(NULL, TEXT("The engine couldn't save the updated settings to a file."), TEXT("Error!"), MB_OK);
      return nRet;
   }

   //...
   //...
   //...

   L_Doc2DeleteSettingsCollection(hDoc, nSId);
   nRet = L_Doc2ShutDown (&hDoc);
   if(nRet != SUCCESS)
      return nRet;

   return SUCCESS;

}