Creates a copy of the page.
#include "ltocr.h"
L_LTOCR_API L_INT EXT_FUNCTION L_OcrPage_Copy(page, targetPage)
Handle to the OCR page.
Pointer to a handle of the newly created page.
| Value | Meaning |
|---|---|
| SUCCESS | The function was successful. |
| < 1 | An error occurred. Refer to Return Codes. |
This function performs the following steps:
Creates a new OCR page with a copy of the image in the source page.
Copies any zones found in the source page to the newly created page.
Copies any recognized results to the newly created page.
The target page will have no link whatsoever to the source page and must be disposed of when no longer used.
If the source page does not have an area of interest, the target will be an exact copy of the page.
If the source page contains an area of interest previously set through L_OcrPage_SetAreaOptions, only the rectangle specified in L_OcrPageAreaOptions.Area is obtained. The target page will have dimensions equal to the Area. Only the zones and recognized characters that are included in the area are copied.
L_INT L_OcrPage_CopyExample(){L_INT retCode = SUCCESS;BITMAPHANDLE bitmap = { 0 };L_OcrEngine ocrEngine = NULL;L_OcrPage ocrPageSource = NULL;L_OcrPage ocrPageDest = 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)goto CLEANUP;// Start the engine using default parametersretCode = L_OcrEngine_Startup(ocrEngine, NULL, OCR_LEAD_RUNTIME_DIR);if (retCode != SUCCESS)goto CLEANUP;// Load an image to processretCode = L_LoadBitmap(MAKE_IMAGE_PATH(L_TEXT("Ocr1.tif")), &bitmap, sizeof(BITMAPHANDLE), 0, ORDER_RGB, NULL, NULL);if (retCode != SUCCESS)goto CLEANUP;// Add the image to an OCR pageretCode = L_OcrPage_FromBitmap(ocrEngine, &ocrPageSource, &bitmap, L_OcrBitmapSharingMode_AutoFree, NULL, NULL);if (retCode != SUCCESS)goto CLEANUP;// Transfer ownership to the OCR pagememset(&bitmap, 0, sizeof(bitmap));// Recognize itretCode = L_OcrPage_Recognize(ocrPageSource, NULL, NULL);if (retCode != SUCCESS)goto CLEANUP;// Copy to a new ocrPageretCode = L_OcrPage_Copy(ocrPageSource, &ocrPageDest);if (retCode != SUCCESS)goto CLEANUP;// Get the document managerretCode = L_OcrEngine_GetDocumentManager(ocrEngine, &ocrDocumentManager);if (retCode != SUCCESS)goto CLEANUP;// Create an OCR documentretCode = L_OcrDocumentManager_CreateDocument(ocrDocumentManager, &ocrDocument, L_OcrCreateDocumentOptions_AutoDeleteFile, NULL);if (retCode != SUCCESS)goto CLEANUP;// In Document File Mode, add OcrPageDest to OcrDocument after recognitionretCode = L_OcrDocument_AddPage(ocrDocument, ocrPageDest);if (retCode != SUCCESS)goto CLEANUP;// Save the OCR document to a fileretCode = L_OcrDocument_Save(ocrDocument, MAKE_IMAGE_PATH(L_TEXT("Ocr1.pdf")), DOCUMENTFORMAT_PDF, NULL, NULL);CLEANUP:if (bitmap.Flags.Allocated)L_FreeBitmap(&bitmap);if (ocrPageDest != NULL)L_OcrPage_Destroy(ocrPageDest);if (ocrPageSource != NULL)L_OcrPage_Destroy(ocrPageSource);if (ocrDocument != NULL)L_OcrDocument_Destroy(ocrDocument);if (ocrEngine != NULL)L_OcrEngine_Destroy(ocrEngine);return retCode;}