L_OcrEngine_GetDocumentManager

#include "ltocr.h"

L_LTOCR_API L_INT EXT_FUNCTION L_OcrEngine_GetDocumentManager(engine, documentManager)

Returns a handle to the OCR document manager.

Parameters

L_OcrEngine engine

Handle to the OCR engine.

L_OcrDocumentManager* documentManager

Pointer to L_OcrDocumentManager handle to be updated.

Returns

Value Meaning
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

See Also

Functions

Topics

Example

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 20.0.2020.4.2
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2020 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS OCR Module - LEAD Engine C API Help