←Select platform

OcrWriteXmlOptions Constructor()

Summary
Initializes a new instance of OcrWriteXmlOptions with default values.
Syntax
C#
C++/CLI
Java
Python
public OcrWriteXmlOptions() 
public: 
OcrWriteXmlOptions(); 
__init__() # Default constructor 
Remarks

This constructor will initialize the members as follows:

Member Value
Formatted

true

Indent

Two spaces " "

Encoding

OcrXmlEncoding.UTF8

Example
C#
using Leadtools; 
using Leadtools.Codecs; 
using Leadtools.Ocr; 
using Leadtools.Forms.Common; 
using Leadtools.Document.Writer; 
using Leadtools.WinForms; 
using Leadtools.Drawing; 
using Leadtools.ImageProcessing; 
using Leadtools.ImageProcessing.Color; 
 
private static void OcrWriteXmlOptionsExample() 
{ 
   var imageFileName = Path.Combine(LEAD_VARS.ImagesDir, "Ocr1.tif"); 
   var formattedFileName = Path.Combine(LEAD_VARS.ImagesDir, "formatted.xml"); 
   var nonFormattedFileName = Path.Combine(LEAD_VARS.ImagesDir, "non_formatted.xml"); 
 
   using (IOcrEngine ocrEngine = OcrEngineManager.CreateEngine(OcrEngineType.LEAD)) 
   { 
      ocrEngine.Startup(null, null, null, LEAD_VARS.OcrLEADRuntimeDir); 
 
      // Load an image 
      var rasterImage = ocrEngine.RasterCodecsInstance.Load(imageFileName, 1); 
 
      // Create an OCR page from it 
      using (IOcrPage ocrPage = ocrEngine.CreatePage(rasterImage, OcrImageSharingMode.AutoDispose)) 
      { 
         // Recognize 
         ocrPage.Recognize(null); 
 
         // Save the result as XML 
 
         // First, non-formatted 
         var writeXmlOptions = new OcrWriteXmlOptions(); 
         writeXmlOptions.Formatted = false; 
         ocrPage.SaveXml(formattedFileName, 1, writeXmlOptions, OcrXmlOutputOptions.None); 
 
         // Next, formatted with 4 spaces indentation 
         writeXmlOptions.Formatted = true; 
         writeXmlOptions.Indent = "  "; 
         ocrPage.SaveXml(nonFormattedFileName, 1, writeXmlOptions, OcrXmlOutputOptions.None); 
      } 
   } 
} 
 
static class LEAD_VARS 
{ 
   public const string ImagesDir = @"C:\LEADTOOLS23\Resources\Images"; 
   public const string OcrLEADRuntimeDir = @"C:\LEADTOOLS23\Bin\Common\OcrLEADRuntime"; 
} 
Requirements

Target Platforms

Help Version 23.0.2024.4.19
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2024 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.Ocr Assembly
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.