[SerializableAttribute()]
public class OcrWriteXmlOptions
@interface LTOcrWriteXmlOptions : NSObject
public class OcrWriteXmlOptions
[SerializableAttribute()]
public ref class OcrWriteXmlOptions
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))
{
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";
}
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
Your email has been sent to support! Someone should be in touch! If your matter is urgent please come back into chat.
Chat Hours:
Monday - Friday, 8:30am to 6pm ET
Thank you for your feedback!
Please fill out the form again to start a new chat.
All agents are currently offline.
Chat Hours:
Monday - Friday
8:30AM - 6PM EST
To contact us please fill out this form and we will contact you via email.