#include "ltocr.h"

L_LTOCR_API L_INT EXT_FUNCTION L_OcrPage_SaveXml(page, fileName, pageNumber, xmlOptions, outputOptions)

L_OcrPage page; handle to the OCR page
const L_TCHAR* fileName; the output file name to save the XML data to
L_UINT pageNumber; 1-based page number to use
const L_OcrWriteXmlOptions* xmlOptions; options to use when creating the XML data.
L_OcrXmlOutputOptions outputOptions; a combination of one or more L_OcrXmlOutputOptions enumeration members that specify the XML generation options

Converts the cumulated recognition result stored in this page to XML data and stores it in a disk file with XML options.

Parameter Description
page Handle to the OCR page.
fileName The output file name to save the XML data to.
pageNumber 1-based page number to use.
xmlOptions Options to use when creating the XML data.
outputOptions A combination of one or more OcrXmlOutputOptions enumeration members that specify the XML generation options.


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


Converts the cumulated recognition result stored in this page to XML data and stores it in a disk file with XML options.

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_AddZone, 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_GetRecognizedCharacters, L_OcrPage_SetRecognizedCharacters, 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_GetAutoPreprocessValues
Topics: Programming with LEADTOOLS OCR Module - LEAD Engine
Starting and Shutting Down the OCR Engine
Recognizing OCR Pages
Working With OCR Pages


L_INT L_OcrPage_SaveXmlExample() 
   BITMAPHANDLE bitmap = { 0 }; 
   L_OcrEngine ocrEngine = NULL; 
   L_OcrPage ocrPage = NULL; 
   // Create an instance of the engine 
   L_INT 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); 
   // Load an image to process 
   L_LoadBitmap(MAKE_IMAGE_PATH(L_TEXT("Ocr1.tif")), &bitmap, sizeof(BITMAPHANDLE), 0, ORDER_RGB, NULL, NULL); 
   // Add the image to an OCR page 
   L_OcrPage_FromBitmap(ocrEngine, &ocrPage, &bitmap, L_OcrBitmapSharingMode_AutoFree, NULL, NULL); 
   // Transfer ownership to the OCR page 
   bitmap.Flags.Allocated = 0; 
   // Recognize it 
   L_OcrPage_Recognize(ocrPage, NULL, NULL); 
   // Save the result XML to a disk file 
   L_OcrWriteXmlOptions ocrWriteXmlOptions; 
   ocrWriteXmlOptions.StructSize = sizeof(L_OcrWriteXmlOptions); 
   ocrWriteXmlOptions.Encoding = L_OcrXmlEncoding_UTF8; 
   ocrWriteXmlOptions.Formatted = true; 
   wsprintf(ocrWriteXmlOptions.Indent, TEXT("   ")); 
   retCode = L_OcrPage_SaveXml(ocrPage, MAKE_IMAGE_PATH(L_TEXT("Ocr1.xml")), 0, &ocrWriteXmlOptions, L_OcrXmlOutputOptions_CharacterAttributes); 
   // Done with this, so we can dispose of it. 
   ocrPage = NULL; 
   if(ocrPage != NULL) 
   if(ocrEngine != NULL) 
   return SUCCESS; 
Help Version 20.0.2019.3.12
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2019 LEAD Technologies, Inc. All Rights Reserved.