Returns a handle to the OCR document manager.
#include "ltocr.h"
L_LTOCR_API L_INT EXT_FUNCTION L_OcrEngine_GetDocumentManager(engine, documentManager)
Handle to the OCR engine.
Pointer to L_OcrDocumentManager 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 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:
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 engineretCode = L_OcrEngineManager_CreateEngine(L_OcrEngineType_LEAD, &ocrEngine);if(retCode != SUCCESS)return retCode;// Start the engine using default parametersL_OcrEngine_Startup(ocrEngine, NULL, OCR_LEAD_RUNTIME_DIR);//Create an OCR documentL_OcrEngine_GetDocumentManager(ocrEngine, &ocrDocumentManager);L_OcrDocumentManager_CreateDocument(ocrDocumentManager, &ocrDocument, L_OcrCreateDocumentOptions_AutoDeleteFile, NULL);// Get the format options for PDFDOCWRTPDFOPTIONS pdfOptions;pdfOptions.Options.uStructSize = sizeof(DOCWRTPDFOPTIONS);L_OcrDocumentManager_GetFormatOptions(ocrDocumentManager, DOCUMENTFORMAT_PDF, &pdfOptions.Options);// Set the specific PDF options we wantpdfOptions.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 optionsL_OcrDocumentManager_SetFormatOptions(ocrDocumentManager, DOCUMENTFORMAT_PDF, &pdfOptions.Options);for(int i = 1; i <= 4; i++){//Create a BITMAPHANDLEBITMAPHANDLE 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 PageL_OcrPage ocrPage = NULL;L_OcrPage_FromBitmap(ocrEngine, &ocrPage, &bitmap, L_OcrBitmapSharingMode_AutoFree, NULL, NULL);//Transfer ownershipbitmap.Flags.Allocated = 0;//Recognize pageL_OcrPage_Recognize(ocrPage, NULL, NULL);//Add OCR Page to OCR documentL_OcrDocument_AddPage(ocrDocument, ocrPage);//Destroy OCR page to free bitmap & recognition data in memoryL_OcrPage_Destroy(ocrPage);}// Save OCR recognition to PDFL_OcrDocument_Save(ocrDocument, MAKE_IMAGE_PATH(L_TEXT("Ocr.pdf")), DOCUMENTFORMAT_PDF, NULL, NULL);//CLEANUPif(ocrDocument != NULL)L_OcrDocument_Destroy(ocrDocument);if(ocrEngine != NULL)L_OcrEngine_Destroy(ocrEngine);return SUCCESS;}