←Select platform

Format Property

Summary
Gets the document format type associated with this options class.
Syntax
C#
Objective-C
C++/CLI
Java
Python
public override DocumentFormat Format { get; } 
@property (nonatomic, assign, readonly) LTDocumentFormat format 
@Override public DocumentFormat getFormat() 
public: 
property DocumentFormat Format { 
   DocumentFormat get() override; 
} 
Format # get  (AltoXmlDocumentOptions) 

Property Value

This property will always return DocumentFormat.AltoXml.

Remarks

This property is required internally by LEADTOOLS.

Example
C#
Java
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:\LEADTOOLS23\Resources\Images"; 
   public const string OcrLEADRuntimeDir = @"C:\LEADTOOLS23\Bin\Common\OcrLEADRuntime"; 
} 
 
import static org.junit.Assert.assertTrue; 
 
import java.io.File; 
import java.io.IOException; 
import org.junit.*; 
import org.junit.runner.JUnitCore; 
import org.junit.runner.Result; 
import org.junit.runner.notification.Failure; 
 
import leadtools.codecs.*; 
import leadtools.ocr.*; 
import leadtools.document.writer.*; 
 
 
public void altoXmlDocumentOptionsExample() { 
   final String LEAD_VARS_IMAGES_DIR = "C:\\LEADTOOLS23\\Resources\\Images"; 
   final String OCR_LEAD_RUNTIME_DIR = "C:\\LEADTOOLS23\\Bin\\Common\\OcrLEADRuntime"; 
 
   String inputFileName = combine(LEAD_VARS_IMAGES_DIR, "ocr2.tif"); 
   String outputFileName = combine(LEAD_VARS_IMAGES_DIR, "out_Example.xml"); 
 
   // Setup LEADTOOLS OCR engine 
   OcrEngine ocrEngine = OcrEngineManager.createEngine(OcrEngineType.LEAD); 
   ocrEngine.startup(null, null, null, OCR_LEAD_RUNTIME_DIR); 
 
   // Get the DocumentWriter instance 
   DocumentWriter docWriter = new DocumentWriter(); 
 
   // Change the ALTO XML options 
   AltoXmlDocumentOptions altoXmlOptions = (AltoXmlDocumentOptions) docWriter.getOptions(DocumentFormat.ALTO_XML); 
   altoXmlOptions.setSoftwareCreator("LEAD"); 
   docWriter.setOptions(DocumentFormat.ALTO_XML, altoXmlOptions); 
 
   // Create a document 
   OcrDocument ocrDocument = ocrEngine.getDocumentManager().createDocument(); 
 
   // Add the image 
   RasterCodecs c = new RasterCodecs(); 
   OcrPage ocrPage = ocrDocument.getPages().addPage(c.load(inputFileName), null); // ocr progress listener, callback 
                                                                                  // in correct format needed 
 
   // Recognize it 
   ocrPage.recognize(null); 
 
   // Save the document as ALTO XML 
   ocrDocument.save(outputFileName, DocumentFormat.ALTO_XML, null); 
 
   ocrEngine.dispose(); 
   ocrDocument.dispose(); 
 
   assertTrue("Document unsuccessfully saved", new File(outputFileName).exists()); 
   System.out.println("Successful, document saved to " + outputFileName); 
} 
Requirements

Target Platforms

Help Version 23.0.2024.2.29
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2024 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.