Returns a handle to the OCR engine spell check manager.


#include "ltocr.h"

L_LTOCR_API L_INT EXT_FUNCTION L_OcrEngine_GetSpellCheckManager(engine, spellCheckManager)


L_OcrEngine engine

Handle to the OCR engine.

L_OcrSpellCheckManager* spellCheckManager

Pointer to a L_OcrSpellCheckManager handle to be updated.


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


This function returns a handle to the OCR engine spell check manager which allows you to enable/disable the spell checking system as well to maintain language and user dictionaries.

The L_OcrSpellCheckManager allows you to do the following:

Required DLLs and Libraries

See Also




L_INT L_OcrEngine_GetSpellCheckManagerExample() 
   BITMAPHANDLE bitmap = { 0 }; 
   L_OcrEngine ocrEngine = NULL; 
   L_OcrPage ocrPage = NULL; 
   L_OcrSpellCheckManager spellCheckManager = NULL; 
   L_OcrDocumentManager ocrDocumentManager = NULL; 
   L_OcrDocument ocrDocument = NULL; 
   L_OcrLanguage* languages; 
   L_UINT languageCount = 0; 
   L_SpellChecker spellChecker = NULL; 
   L_OcrZone zone = {0}; 
   // Create an instance of the engine 
   L_INT retCode = L_OcrEngineManager_CreateEngine(L_OcrEngineType_LEAD, &ocrEngine); 
   if(retCode != SUCCESS) 
      return retCode; 
   // Start the engine using default parameters 
   L_OcrEngine_Startup(ocrEngine, NULL, OCR_LEAD_RUNTIME_DIR); 
   L_OcrEngine_GetSpellCheckManager(ocrEngine, &spellCheckManager); 
   // Get the spell language supported (languages with a dictionary) 
   L_OcrSpellCheckManager_GetSupportedLanguages(spellCheckManager, &languages, &languageCount); 
   for(L_UINT index = 0; index < languageCount; index++) 
      std::cout << languages[index] << std::endl; 
      // Check if English is supported 
      if(L_OcrSpellCheckManager_IsLanguageSupported(spellCheckManager, L_OcrLanguage_EN)) 
         // Yes, set it 
         L_OcrSpellCheckManager_GetSpellChecker(spellCheckManager, languages[index], &spellChecker); 
         L_OcrLanguage language; 
         L_SpellChecker_GetLanguage(spellChecker, &language); 
         std::cout << "Current spell language: " << language << std::endl; 
   // Enable the Native spell check engine 
   L_OcrSpellCheckEngine spellCheckEngine; 
   L_OcrSpellCheckManager_GetSpellCheckEngine(spellCheckManager, &spellCheckEngine); 
   if(spellCheckEngine != L_OcrSpellCheckEngine_Native) 
      L_OcrSpellCheckManager_SetSpellCheckEngine(spellCheckManager, L_OcrSpellCheckEngine_Native); 
   // Load a page to be recognized 
   retCode = L_LoadBitmap(MAKE_IMAGE_PATH(L_TEXT("Ocr1.tif")), &bitmap, sizeof(BITMAPHANDLE), 0, ORDER_RGB, NULL, NULL); 
   if(retCode != SUCCESS) 
      goto CLEANUP; 
   // Add an image to OCR page. Transfer ownership of the bitmap to the page 
   retCode = L_OcrPage_FromBitmap(ocrEngine, &ocrPage, &bitmap, L_OcrBitmapSharingMode_AutoFree, NULL, NULL); 
   if(retCode != SUCCESS) 
      goto CLEANUP; 
   // We have a valid page and bitmap ownership has transfered. So, we do not need to free the bitmap anymore. 
   // Bitmap will be freed when ocrPage is destroyed. 
   bitmap.Flags.Allocated = 0; 
   //Get the document manager 
   retCode = L_OcrEngine_GetDocumentManager(ocrEngine, &ocrDocumentManager); 
   if(retCode != SUCCESS) 
      goto CLEANUP; 
   // Create memory-based OCR document 
   retCode = L_OcrDocumentManager_CreateDocument(ocrDocumentManager, &ocrDocument, L_OcrCreateDocumentOptions_InMemory, NULL); 
   if(retCode != SUCCESS) 
      goto CLEANUP; 
   // Add page to the document. 
   retCode = L_OcrDocument_AddPage(ocrDocument, ocrPage); 
   if(retCode != SUCCESS) 
      goto CLEANUP; 
   // Next, we are going to show the effect of using L_OcrSpellCheckManager_AddUserWords function 
   // in order to do so we are going to add manual zone around specific line inside the image OCR1.TIF 
   // this line contains the word "ePrint", if you didn't use the L_OcrSpellCheckManager_AddUserWords 
   // function to add the word "ePrint" to the English user dictionary then the engine will internally  
   // try to spell it and then it will convert the capital "P" letter into small "p" so it will become 
   // "eprint", but if you used the L_OcrSpellCheckManager_AddUserWords function to add this word into  
   // dictionary then you will notice that it appears as is ("ePrint") int he output document, and this  
   // is because the engine will find it in the dictionary and won't try to correct it during spell  
   // checking phase. 
   // so in order to show the difference we are going recognize/save the manual zone without calling 
   // L_OcrSpellCheckManager_AddUserWords function then do it again after calling it so you can see  
   // the difference between both output files. 
   // Add manual zone around specific line at the bottom of the image 
   zone.ZoneType = L_OcrZoneType_Text; 
   zone.Bounds.left = 360; 
   zone.Bounds.top = 2640; 
   zone.Bounds.right = 2190; 
   zone.Bounds.bottom = 2700; 
   retCode = L_OcrPage_AddZone(ocrPage, &zone); 
   if(retCode != SUCCESS) 
      goto CLEANUP; 
   // Recognize the page 
   retCode = L_OcrPage_Recognize(ocrPage, NULL, NULL); 
   if(retCode != SUCCESS) 
      goto CLEANUP; 
   // Save the document we have as DOC 
   retCode = L_OcrDocument_Save(ocrDocument, MAKE_IMAGE_PATH(L_TEXT("Test1.doc")), DOCUMENTFORMAT_DOC, NULL, NULL); 
   if(retCode != SUCCESS) 
      goto CLEANUP; 
   // Now call the L_OcrSpellCheckManager_AddUserWords function adding the word "ePrint" to user dictionary, recognize and save again. 
   L_WCHAR userWords[MAX_PATH]; 
   memset(userWords, 0, MAX_PATH * sizeof(L_WCHAR)); 
   wcscpy_s(userWords, MAX_PATH, L"ePrint"); 
   retCode = L_OcrSpellCheckManager_AddUserWords(spellCheckManager, L_OcrLanguage_EN, userWords); 
   // Recognize and save page again 
   retCode = L_OcrPage_Recognize(ocrPage, NULL, NULL); 
   if(retCode != SUCCESS) 
      goto CLEANUP; 
   retCode = L_OcrDocument_Save(ocrDocument, MAKE_IMAGE_PATH(L_TEXT("Test2.doc")), DOCUMENTFORMAT_DOC, NULL, NULL); 
   if(retCode != SUCCESS) 
      goto CLEANUP; 
   // Now open the output document Test1.doc and Test2.doc and see that in Test1.doc the word "ePrint" is all small letter 
   // while in the second document Test2.doc the word is "ePrint" and this is because no suggestions were generated in the 
   // second time since the word was found in the English dictionary. 
   if(ocrPage != NULL) 
   if(ocrDocument != NULL) 
   if(ocrEngine != NULL) 
   return SUCCESS; 
Help Version 23.0.2024.2.29
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2024 LEAD Technologies, Inc. All Rights Reserved.


Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.