L_DocStartUp

#include "ltdoc.h"

L_LTDOC_API L_INT L_DocStartUp(phDoc, pszEnginePath, bUseThunk)

L_HDOC * 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 are:

 

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

L_DocStartUp must be called before calling any other LEADTOOLS OCR document toolkit functions.

The user must unlock the OCR document toolkit using the L_UnlockSupport function. If the OCR document toolkit is locked then the L_DocStartUp 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 L_DocShutDown. For every call to L_DocStartUp there must be an associated call to L_DocShutDown.

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.

Note: bUseThunk parameter is added to LEADTOOLS version 16 or later.

Required DLLs and Libraries

LTDOC

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_DocShutDown

Topics:

OCR Functions: Starting and Shutting Down

 

Starting and Shutting Down the Engine

 

Starting and Shutting Down the Engine

Example

 L_INT DocStartUpExample(L_TCHAR* pszSettingFile)
{
   L_INT nRet ;
   L_HDOC hDoc = NULL;

#if defined(LEADTOOLS_V16_OR_LATER)
   nRet = L_DocStartUp(&hDoc, NULL, FALSE);
#else
   nRet = L_DocStartUp(&hDoc, NULL);
#endif // #if defined(LEADTOOLS_V16_OR_LATER)
   if (nRet != SUCCESS)
      return nRet;

   /* Unlock OCR support.
      Note that this is a sample key, which will not work in your toolkit. */
   L_UnlockSupport(L_SUPPORT_OCR, L_KEY_OCR);
   
   nRet = L_DocLoadSettings(hDoc, pszSettingFile);
   if(nRet != SUCCESS)
      return nRet;

   FILLMETHOD fm;
   nRet = L_DocGetFillMethod(hDoc, &fm);
   if (nRet == SUCCESS)
   {
      if (fm != FILL_HANDPRINT)
      {
         nRet = L_DocSetFillMethod(hDoc, FILL_HANDPRINT);
         if(nRet != SUCCESS)
            return nRet;
      }
   }
   else
   {
      return nRet;
   }

   nRet = L_DocSaveSettings (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;
   }

   nRet = L_DocShutDown (&hDoc);
   if(nRet != SUCCESS)
      return nRet;

   return SUCCESS;

}