Error processing SSI file
LEADTOOLS Forms (Leadtools.Forms.DocumentWriters assembly)

Show in webframe

AltoXmlDocumentOptions Class








Members 
Provides extra options to use when saving a document using the ALTO (Analyzed Layout and Text Object) format.
Object Model
Syntax
[DataContractAttribute()]
[SerializableAttribute()]
public class AltoXmlDocumentOptions : DocumentOptions 
'Declaration
 
<DataContractAttribute()>
<SerializableAttribute()>
Public Class AltoXmlDocumentOptions 
   Inherits DocumentOptions
'Usage
 
Dim instance As AltoXmlDocumentOptions
public sealed class AltoXmlDocumentOptions : DocumentOptions 
@interface LTAltoXmlDocumentOptions : LTDocumentOptions <NSCopying, NSCoding>
public class AltoXmlDocumentOptions extends DocumentOptions
function Leadtools.Forms.DocumentWriters.AltoXmlDocumentOptions()
[DataContractAttribute()]
[SerializableAttribute()]
public ref class AltoXmlDocumentOptions : public 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.

Copy Code  
Imports Leadtools.Forms.DocumentWriters
Imports Leadtools
Imports Leadtools.Codecs
Imports Leadtools.Forms.Ocr

      
Public Sub AltoXmlDocumentOptionsExample()
   Dim inputFileName As String = Path.Combine(LEAD_VARS.ImagesDir, "ocr1.tif")
   Dim outputFileName As String = Path.Combine(LEAD_VARS.ImagesDir, "Example.xml")
   ' Setup LEADTOOLS OCR engine
   Using ocrEngine As IOcrEngine = OcrEngineManager.CreateEngine(OcrEngineType.Advantage, False)
      ocrEngine.Startup(Nothing, Nothing, Nothing, LEAD_VARS.OcrAdvantageRuntimeDir)

      ' Get the DocumentWriter instance
      Dim docWriter As New DocumentWriter()
      ' Change the ALTO XML options
      Dim altoXmlOptions As AltoXmlDocumentOptions = DirectCast(docWriter.GetOptions(DocumentFormat.AltoXml), AltoXmlDocumentOptions)
      altoXmlOptions.FileName = inputFileName
      altoXmlOptions.SoftwareCreator = "LEAD"
      docWriter.SetOptions(DocumentFormat.AltoXml, altoXmlOptions)

      ' Create a document
      Using ocrDocument As IOcrDocument = ocrEngine.DocumentManager.CreateDocument()
         ' Add the image
         Dim ocrPage As IOcrPage = ocrDocument.Pages.AddPage(inputFileName, Nothing)

         ' Recognize it
         ocrPage.Recognize(Nothing)

         ' Save the document as ALTO XML
         ocrDocument.Save(outputFileName, DocumentFormat.AltoXml, Nothing)
      End Using
   End Using
End Sub

Public NotInheritable Class LEAD_VARS
Public Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images"
Public Const OcrAdvantageRuntimeDir As String = "C:\LEADTOOLS 19\Bin\Common\OcrAdvantageRuntime"
End Class
using Leadtools.Forms.DocumentWriters;
using Leadtools;
using Leadtools.Codecs;
using Leadtools.Forms.Ocr;

public void AltoXmlDocumentOptionsExample()
{
   var inputFileName = Path.Combine(LEAD_VARS.ImagesDir, "ocr1.tif");
   var outputFileName = Path.Combine(LEAD_VARS.ImagesDir, "Example.xml");
   // Setup LEADTOOLS OCR engine
   using (var ocrEngine = OcrEngineManager.CreateEngine(OcrEngineType.Advantage, false))
   {
      ocrEngine.Startup(null, null, null, LEAD_VARS.OcrAdvantageRuntimeDir);

      // 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:\Users\Public\Documents\LEADTOOLS Images";
public const string OcrAdvantageRuntimeDir = @"C:\LEADTOOLS 19\Bin\Common\OcrAdvantageRuntime";
}
Requirements

Target Platforms

See Also

Reference

AltoXmlDocumentOptions Members
Leadtools.Forms.DocumentWriters Namespace
DocumentWriter Class
Programming with LEADTOOLS Document Writers
Files to be Included with Your Application
Unlocking Special LEAD Features

Error processing SSI file
Leadtools.Forms.DocumentWriters requires a Document or Medical toolkit license and unlock key. For more information, refer to: Imaging Pro/Document/Medical Features