←Select platform

AltoXmlDocumentOptions Class

Summary
Provides extra options to use when saving a document using the ALTO (Analyzed Layout and Text Object) format.
Syntax
C#
Objective-C
C++/CLI
Java
Python
[SerializableAttribute()] 
[DataContractAttribute()] 
public class AltoXmlDocumentOptions : DocumentOptions 
@interface LTAltoXmlDocumentOptions : LTDocumentOptions<NSCopying, NSCoding> 
public class AltoXmlDocumentOptions extends DocumentOptions 
[DataContractAttribute()] 
[SerializableAttribute()] 
public ref class AltoXmlDocumentOptions : public DocumentOptions  
class AltoXmlDocumentOptions(DocumentOptions): 
Remarks

The options set in the AltoXmlDocumentOptions class will be used when the user saves a document using the DocumentFormat.AltoXml format.

To change the options used with the Alto format, perform the following steps:

  1. Use the DocumentWriter.GetOptions method of the DocumentWriter object being used. Passing DocumentFormat.AltoXml to the format parameter. Note that the resulting object from the base DocumentOptions class needs to be cast to AltoXmlDocumentOptions.
  2. Use the various AltoXmlDocumentOptions properties to change the options.
  3. Use DocumentWriter.SetOptions to set the new options in the engine.
  4. Now you can call the DocumentWriter.BeginDocument method (again, with DocumentFormat.AltoXml for the format parameter) to create a new document and add the pages.

Note that this format does not support calling DocumentWriter.InsertPage.

Example

This example will create a new text file using some of the supported options.

C#
using Leadtools.Document.Writer; 
using Leadtools; 
using Leadtools.Codecs; 
using Leadtools.Ocr; 
 
 
public void AltoXmlDocumentOptionsExample() 
{ 
   var inputFileName = Path.Combine(LEAD_VARS.ImagesDir, "ocr2.tif"); 
   var outputFileName = Path.Combine(LEAD_VARS.ImagesDir, "out_Example.xml"); 
 
   // Setup LEADTOOLS OCR engine 
   using (var ocrEngine = OcrEngineManager.CreateEngine(OcrEngineType.LEAD)) 
   { 
      ocrEngine.Startup(null, null, null, LEAD_VARS.OcrLEADRuntimeDir); 
 
      // Get the DocumentWriter instance 
      var docWriter = new DocumentWriter(); 
      // Change the ALTO XML options 
      var altoXmlOptions = docWriter.GetOptions(DocumentFormat.AltoXml) as AltoXmlDocumentOptions; 
      altoXmlOptions.FileName = inputFileName; 
      altoXmlOptions.SoftwareCreator = "LEAD"; 
      docWriter.SetOptions(DocumentFormat.AltoXml, altoXmlOptions); 
 
      // Create a document 
      using (var ocrDocument = ocrEngine.DocumentManager.CreateDocument()) 
      { 
         // Add the image 
         var ocrPage = ocrDocument.Pages.AddPage(inputFileName, null); 
 
         // Recognize it 
         ocrPage.Recognize(null); 
 
         // Save the document as ALTO XML 
         ocrDocument.Save(outputFileName, DocumentFormat.AltoXml, null); 
      } 
   } 
} 
 
static class LEAD_VARS 
{ 
   public const string ImagesDir = @"C:\LEADTOOLS22\Resources\Images"; 
   public const string OcrLEADRuntimeDir = @"C:\LEADTOOLS22\Bin\Common\OcrLEADRuntime"; 
} 
Requirements

Target Platforms

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

Leadtools.Document.Writer Assembly

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