#include "ltdoc2.h"

L_LTDOC2_API L_INT L_Doc2RecognizeExt(hDoc, nDocId, pRecogOpts, pfnCallback, pUserData)

Recognizes the specified page(s).


L_HDOC2 hDoc

Handle to the OCR document.

L_INT nDocId

Document ID created by calling L_Doc2CreateDocument.


Pointer to a RECOGNIZEOPTS2 structure containing recognition options.


Optional callback function for reporting recognition status.

If you do not provide a callback function, use NULL as the value of pfnCallback. Use NULL if no progress reporting is needed.

If you do provide a callback function, use the function pointer as the value of pfnCallback.

L_Doc2Recognize / L_Doc2RecognizeExt calls pfnCallback as it reports recognition status for each recognized page. The callback function must adhere to the following function prototype: RECOGNIZESTATUSCALLBACK2.

L_VOID * pUserData

Void pointer used to pass one or more additional parameters that the callback function needs.

To use _pUserData_, assign a value to a variable or create a structure that contains as many fields as you need. Then, in _pUserData_, pass the address of the variable or structure, casting it to L_VOID *. The callback function, which receives the address in its own pUserData parameter, can cast it to a pointer to the appropriate data type to access your variable or structure.

If the additional parameters are not needed, pass NULL in this parameter.


Value Meaning
SUCCESS The function was successful.
< 1 An error occurred. Refer to Return Codes.


L_Doc2RecognizeExt recognizes the specified page or pages from the OCR document. To save the recognition result to a file, call the L_Doc2SaveResultsToFile / L_Doc2SaveResultsToFileExt function.


Zone recognition for the DOC2_RECOGMODULE_OMNIFONT_PLUS2W module is faster but less accurate. Conversely, a DOC2_RECOGMODULE_OMNIFONT_PLUS3W module will be more accurate but slower.

Required DLLs and Libraries

See Also




L_INT EXT_CALLBACK RecognizeStatusCBExt(L_INT nRecogPage, 
                                     L_INT nError, 
                                     L_VOID* pUserData) 
   L_TCHAR szBuffer[100]; 
   ZeroMemory(szBuffer, sizeof(szBuffer)); 
   wsprintf(szBuffer, TEXT("Recognized page index = %d\nRecognition Return value = %d\n"), nRecogPage, nError); 
   MessageBox(NULL, szBuffer, TEXT("Notice!"), MB_OK); 
   return SUCCESS; 
L_INT Doc2RecognizeExampleExt(L_HDOC2 hDoc, L_INT nDocId, L_INT nPageIndex) 
   L_INT nRet; 
   DOC2_LANGIDS* pLangIds = NULL; 
   L_INT nLangCount = 0; 
   nRet = L_Doc2GetDefaultSpellLanguages (hDoc, &pLangIds, &nLangCount); 
   if (nRet == SUCCESS) 
      nRet = L_Doc2GetRecognizeModuleTradeOffExt(hDoc, nDocId, &TradeOff); 
      if(nRet != SUCCESS) 
         return nRet; 
      if (TradeOff != DOC2_RECGMD_ACCURATE) 
         nRet = L_Doc2SetRecognizeModuleTradeOffExt(hDoc, nDocId, DOC2_RECGMD_ACCURATE); 
         if(nRet != SUCCESS) 
            return nRet; 
      RecogOpts.uStructSize = sizeof(RECOGNIZEOPTS2); 
      RecogOpts.nPageIndexStart = nPageIndex; 
      RecogOpts.nPagesCount = 1; 
      RecogOpts.bEnableSubSystem = TRUE; 
      RecogOpts.bEnableCorrection = TRUE; 
      RecogOpts.SpellLangId = pLangIds[0]; 
      nRet = L_Doc2RecognizeExt(hDoc, nDocId, &RecogOpts, RecognizeStatusCBExt, NULL); 
      if(nRet != SUCCESS) 
         return nRet; 
      nRet = L_Doc2FreeLanguages(hDoc, &pLangIds); 
      if(nRet != SUCCESS) 
         return nRet; 
      return nRet; 
   return SUCCESS; 
Help Version 21.0.2021.7.2
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2021 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS OCR Module - OmniPage Engine C API Help
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2021 LEAD Technologies, Inc. All Rights Reserved.