#include "ltocr.h"

L_LTOCR_API L_INT EXT_FUNCTION L_OcrPage_Copy(page, targetPage)

L_OcrPage page; handle to the OCR page
L_OcrPage* targetPage; newly created page

Creates a copy of the page.

Parameter Description
page Handle to the OCR page.
targetPage Pointer to a handle of the newly created page.


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


This function performs the following steps:

  1. Creates a new OCR page with a copy of the image in the source page.

  2. Copies any zones found in the source page to the newly created page.

  3. 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.

Required DLLs and Libraries

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_OcrPage_Destroy, L_OcrPage_FromBitmap, L_OcrPage_GetBitmap, L_OcrPage_SetBitmap, L_OcrPage_GetOverlayBitmap, L_OcrPage_SetOverlayBitmap, L_OcrPage_SetBitmapChangedCallback, L_OcrPage_IsInverted, L_OcrPage_GetRotateAngle, L_OcrPage_GetDeskewAngle, L_OcrPage_AutoPreprocess, L_OcrPage_AutoZone, L_OcrPage_GetZoneCount, L_OcrPage_InsertZone, L_OcrPage_IndexOfZone, L_OcrPage_GetZoneAt, L_OcrPage_SetZoneAt, L_OcrPage_RemoveZone, L_OcrPage_RemoveZoneAt, L_OcrPage_ClearZones, L_OcrPage_GetZoneCells, L_OcrPage_SetZoneCells, L_OcrPage_HitTestZone, L_OcrPage_IsRecognized, L_OcrPage_Recognize, L_OcrPage_Unrecognize, L_OcrPage_GetRecognizeStatistics, L_OcrPage_SetRecognizedCharacters, L_OcrPage_GetRecognizedCharacters, L_OcrPage_FreePageCharacters, L_OcrPage_GetZoneWords, L_OcrPage_FreeWords, L_OcrPage_GetText, L_OcrPage_ExtractZoneMICRData, L_OcrPage_DetectLanguages, L_OcrPage_LoadZonesFile, L_OcrPage_SaveZonesFile, L_OcrPage_SaveXml, L_OcrPage_GetAutoPreprocessValues
Topics: Programming with LEADTOOLS OCR Module - LEAD Engine
Recognizing OCR Pages
Working With OCR Pages


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 engine  
   retCode = L_OcrEngineManager_CreateEngine(L_OcrEngineType_LEAD, &ocrEngine); 
   if (retCode != SUCCESS) 
      goto CLEANUP; 
   // Start the engine using default parameters  
   retCode = L_OcrEngine_Startup(ocrEngine, NULL, OCR_LEAD_RUNTIME_DIR); 
   if (retCode != SUCCESS) 
      goto CLEANUP; 
   // Load an image to process  
   retCode = 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 page  
   retCode = L_OcrPage_FromBitmap(ocrEngine, &ocrPageSource, &bitmap, L_OcrBitmapSharingMode_AutoFree, NULL, NULL); 
   if (retCode != SUCCESS) 
      goto CLEANUP; 
   // Transfer ownership to the OCR page  
   memset(&bitmap, 0, sizeof(bitmap)); 
   // Recognize it  
   retCode = L_OcrPage_Recognize(ocrPageSource, NULL, NULL); 
   if (retCode != SUCCESS) 
      goto CLEANUP; 
   // Copy to a new ocrPage 
   retCode = L_OcrPage_Copy(ocrPageSource, &ocrPageDest); 
   if (retCode != SUCCESS) 
      goto CLEANUP; 
   // Get the document manager  
   retCode = L_OcrEngine_GetDocumentManager(ocrEngine, &ocrDocumentManager); 
   if (retCode != SUCCESS) 
      goto CLEANUP; 
   // Create an OCR document  
   retCode = L_OcrDocumentManager_CreateDocument(ocrDocumentManager, &ocrDocument, L_OcrCreateDocumentOptions_AutoDeleteFile, NULL); 
   if (retCode != SUCCESS) 
      goto CLEANUP; 
   // In Document File Mode, add OcrPageDest to OcrDocument after recognition  
   retCode = L_OcrDocument_AddPage(ocrDocument, ocrPageDest); 
   if (retCode != SUCCESS) 
      goto CLEANUP; 
   // Save the OCR document to a file 
   retCode = L_OcrDocument_Save(ocrDocument, MAKE_IMAGE_PATH(L_TEXT("Ocr1.pdf")), DOCUMENTFORMAT_PDF, NULL, NULL); 
   if (bitmap.Flags.Allocated) 
   if (ocrPageDest != NULL) 
   if (ocrPageSource != NULL) 
   if (ocrDocument != NULL) 
   if (ocrEngine != NULL) 
   return retCode; 
Help Version 20.0.2019.3.12
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2019 LEAD Technologies, Inc. All Rights Reserved.