L_OcrEngine_GetDocumentManager

#include "ltocr.h"

L_LTOCR_API L_INT EXT_FUNCTION L_OcrEngine_GetDocumentManager(engine, documentManager)

L_OcrEngine engine; handle to the OCR engine
L_OcrDocumentManager* documentManager; pointer to L_OcrDocumentManager handle to be updated

Returns a handle to the OCR document manager.

Parameter Description
engine Handle to the OCR engine.
documentManager Pointer to L_OcrDocumentManager handle to be updated.

Returns

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

Comments

This function returns a handle to the OCR engine document manager which allows you to create new OCR documents that are used to create final documents such as PDF or Microsoft Word from the recognition results.

The L_OcrDocumentManager allows you to do the following:

Required DLLs and Libraries

LTOCR
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_OcrEngineManager_CreateEngine, L_OcrEngine_Startup, L_OcrEngine_Shutdown, L_OcrEngine_Destroy, L_OcrEngine_GetEngineType, L_OcrEngine_IsStarted, L_OcrEngine_GetSettingManager, L_OcrEngine_GetLanguageManager, L_OcrEngine_GetSpellCheckManager, L_OcrEngine_GetZoneManager, L_OcrEngine_GetAutoRecognizeManager, L_OcrEngine_GetWorkDirectory, L_OcrEngine_GetEngineDirectory
Topics: Programming with LEADTOOLS OCR Advantage
Starting and Shutting Down the OCR Engine
LEADTOOLS OCR Advantage Engine Settings

Example

#define MAKE_IMAGE_PATH(pFileName) TEXT("C:\\Users\\Public\\Documents\\LEADTOOLS Images\\")pFileName 
#define OCR_ADVANTAGE_RUNTIME_DIR TEXT("C:\\LEADTOOLS 19\\Bin\\Common\\OcrAdvantageRuntime") 
L_INT L_OcrEngine_GetDocumentManagerExample() 
{ 
   L_INT retCode = -1; 
   L_OcrEngine ocrEngine = NULL; 
   L_OcrDocumentManager ocrDocumentManager = NULL; 
   L_OcrDocument ocrDocument = NULL; 
   // Create an instance of the engine 
   retCode = L_OcrEngineManager_CreateEngine(L_OcrEngineType_Advantage, &ocrEngine); 
   if(retCode != SUCCESS) 
      return retCode; 
   // Start the engine using default parameters 
   L_OcrEngine_Startup(ocrEngine, NULL, OCR_ADVANTAGE_RUNTIME_DIR); 
   //Create an OCR document 
   L_OcrEngine_GetDocumentManager(ocrEngine, &ocrDocumentManager); 
   L_OcrDocumentManager_CreateDocument(ocrDocumentManager, &ocrDocument, L_OcrCreateDocumentOptions_AutoDeleteFile, NULL); 
   // Get the format options for PDF 
   DOCWRTPDFOPTIONS pdfOptions; 
   pdfOptions.Options.uStructSize = sizeof(DOCWRTPDFOPTIONS); 
   L_OcrDocumentManager_GetFormatOptions(ocrDocumentManager, DOCUMENTFORMAT_PDF, &pdfOptions.Options); 
   // Set the specific PDF options we want 
   pdfOptions.FontEmbed = DOCWRTFONTEMBED_AUTO; 
   pdfOptions.bImageOverText = false; 
   pdfOptions.bLinearized = false; 
   pdfOptions.pwszTitle = L_TEXT("Add your title here"); 
   pdfOptions.pwszSubject = L_TEXT ("Add your subject here"); 
   pdfOptions.pwszKeywords = L_TEXT("Add your keywords here"); 
   pdfOptions.pwszAuthor = L_TEXT("Add author name here"); 
   // Give the engine our updated PDF options 
   L_OcrDocumentManager_SetFormatOptions(ocrDocumentManager, DOCUMENTFORMAT_PDF, &pdfOptions.Options); 
   for(int i = 1; i <= 4; i++) 
   { 
      //Create a BITMAPHANDLE 
      BITMAPHANDLE bitmap = { 0 }; 
      L_TCHAR fileName[MAX_PATH] = {0}; 
      //wcscpy_s(fileName, MAX_PATH, MAKE_IMAGE_PATH(L_TEXT(""))); 
      wsprintf(fileName, MAKE_IMAGE_PATH(TEXT("Ocr%d.tif")), i); 
      L_LoadBitmap(fileName, &bitmap, sizeof(BITMAPHANDLE), 0, ORDER_RGB, NULL, NULL); 
      //Add bitmap to OCR Page 
      L_OcrPage ocrPage = NULL; 
      L_OcrPage_FromBitmap(ocrEngine, &ocrPage, &bitmap, L_OcrBitmapSharingMode_AutoFree, NULL, NULL); 
      //Transfer ownership 
      bitmap.Flags.Allocated = 0; 
      //Recognize page 
      L_OcrPage_Recognize(ocrPage, NULL, NULL); 
      //Add OCR Page to OCR document 
      L_OcrDocument_AddPage(ocrDocument, ocrPage); 
      //Destroy OCR page to free bitmap & recognition data in memory 
      L_OcrPage_Destroy(ocrPage); 
   } 
   // Save OCR recognition to PDF 
   L_OcrDocument_Save(ocrDocument, MAKE_IMAGE_PATH(L_TEXT("Ocr.pdf")), DOCUMENTFORMAT_PDF, NULL, NULL); 
   //CLEANUP 
   if(ocrDocument != NULL) 
      L_OcrDocument_Destroy(ocrDocument); 
   if(ocrEngine != NULL) 
      L_OcrEngine_Destroy(ocrEngine); 
   return SUCCESS; 
} 

Help Version 19.0.2017.10.27
Products | Support | Contact Us | Copyright Notices
© 1991-2017 LEAD Technologies, Inc. All Rights Reserved.
LEADTOOLS Advantage OCR C API Help