Options to use when saving XML data.
[SerializableAttribute()]public class OcrWriteXmlOptions
<SerializableAttribute()>Public Class OcrWriteXmlOptions
@interface LTOcrWriteXmlOptions : NSObject public class OcrWriteXmlOptions [SerializableAttribute()]public ref class OcrWriteXmlOptions
OcrWriteXmlOptions allows to control how XML data is written. It has the following members:
| Member | Description |
|---|---|
| Encoding |
Set the encoding of the XML data. UTF8 or UTF16 |
| Formatted |
Format the document for human reading |
| Indent |
The string to use for indentation when saving the XML data. |
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, false)){ocrEngine.Startup(null, null, null, LEAD_VARS.OcrLEADRuntimeDir);// Load an imagevar rasterImage = ocrEngine.RasterCodecsInstance.Load(imageFileName, 1);// Create an OCR page from itusing (IOcrPage ocrPage = ocrEngine.CreatePage(rasterImage, OcrImageSharingMode.AutoDispose)){// RecognizeocrPage.Recognize(null);// Save the result as XML// First, non-formattedvar writeXmlOptions = new OcrWriteXmlOptions();writeXmlOptions.Formatted = false;ocrPage.SaveXml(formattedFileName, 1, writeXmlOptions, OcrXmlOutputOptions.None);// Next, formatted with 4 spaces indentationwriteXmlOptions.Formatted = true;writeXmlOptions.Indent = " ";ocrPage.SaveXml(nonFormattedFileName, 1, writeXmlOptions, OcrXmlOutputOptions.None);}}}static class LEAD_VARS{public const string ImagesDir = @"C:\Users\Public\Documents\LEADTOOLS Images";public const string OcrLEADRuntimeDir = @"C:\LEADTOOLS 20\Bin\Common\OcrLEADRuntime";}
Imports LeadtoolsImports Leadtools.CodecsImports Leadtools.OcrImports Leadtools.FormsImports Leadtools.Document.WriterImports Leadtools.WinFormsImports Leadtools.DrawingImports Leadtools.ImageProcessingImports Leadtools.ImageProcessing.ColorPrivate Shared Sub OcrWriteXmlOptionsExample()Dim imageFileName As String = Path.Combine(LEAD_VARS.ImagesDir, "Ocr1.tif")Dim formattedFileName As String = Path.Combine(LEAD_VARS.ImagesDir, "formatted.xml")Dim nonFormattedFileName As String = Path.Combine(LEAD_VARS.ImagesDir, "non_formatted.xml")Using ocrEngine As IOcrEngine = OcrEngineManager.CreateEngine(OcrEngineType.LEAD, False)ocrEngine.Startup(Nothing, Nothing, Nothing, LEAD_VARS.OcrLEADRuntimeDir)' Load an imageDim rasterImage As RasterImage = ocrEngine.RasterCodecsInstance.Load(imageFileName, 1)' Create an OCR page from itUsing ocrPage As IOcrPage = ocrEngine.CreatePage(rasterImage, OcrImageSharingMode.AutoDispose)' RecognizeocrPage.Recognize(Nothing)' Save the result as XML' First, non-formattedDim writeXmlOptions As New OcrWriteXmlOptions()writeXmlOptions.Formatted = FalseocrPage.SaveXml(formattedFileName, 1, writeXmlOptions, OcrXmlOutputOptions.None)' Next, formatted with 4 spaces indentationwriteXmlOptions.Formatted = TruewriteXmlOptions.Indent = " "ocrPage.SaveXml(nonFormattedFileName, 1, writeXmlOptions, OcrXmlOutputOptions.None)End UsingEnd UsingEnd SubPublic NotInheritable Class LEAD_VARSPublic Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images"Public Const OcrLEADRuntimeDir As String = "C:\LEADTOOLS 20\Bin\Common\OcrLEADRuntime"End Class
Help Collections
Raster .NET | C API | C++ Class Library | HTML5 JavaScript
Document .NET | C API | C++ Class Library | HTML5 JavaScript
Medical .NET | C API | C++ Class Library | HTML5 JavaScript
Medical Web Viewer .NET
Multimedia
Direct Show .NET | C API | Filters
Media Foundation .NET | C API | Transforms
Supported Platforms
.NET, Java, Android, and iOS/macOS Assemblies
Imaging, Medical, and Document
C API/C++ Class Libraries
Imaging, Medical, and Document
HTML5 JavaScript Libraries
Imaging, Medical, and Document
