←Select platform

Operation Property

Summary
Gets the current running operation.
Syntax
C#
Objective-C
C++/CLI
Java
Python
public OcrProgressOperation Operation { get; } 
@property (nonatomic, assign, readonly) LTOcrProgressOperation operation 
public OcrProgressOperation getOperation() 
property OcrProgressOperation Operation { 
   OcrProgressOperation get(); 
} 
Operation # get  (IOcrProgressData) 

Property Value

The current running operation.

Remarks

For a list of the available operations, refer to OcrProgressOperation.

Example
C#
Java
using Leadtools; 
using Leadtools.Codecs; 
using Leadtools.Ocr; 
using Leadtools.Document.Writer; 
using Leadtools.Forms.Common; 
using Leadtools.WinForms; 
 
public void OcrProgressCallbackExample() 
{ 
   string logFileName = Path.Combine(LEAD_VARS.ImagesDir, "log.txt"); 
   string multiPageTifFileName = Path.Combine(LEAD_VARS.ImagesDir, "Ocr.tif"); 
   string pdfFileName = Path.Combine(LEAD_VARS.ImagesDir, "Ocr1.pdf"); 
 
   // Create the log text writer 
   _log = File.CreateText(logFileName); 
 
   // Create an instance of the engine 
   using (IOcrEngine ocrEngine = OcrEngineManager.CreateEngine(OcrEngineType.LEAD)) 
   { 
      // Start the engine using default parameters 
      ocrEngine.Startup(null, null, null, LEAD_VARS.OcrLEADRuntimeDir); 
 
      // Create an OCR document 
      using (IOcrDocument ocrDocument = ocrEngine.DocumentManager.CreateDocument()) 
      { 
         // Add this image to the document 
         _log.WriteLine("Adding the pages"); 
         _log.WriteLine("********************************"); 
         ocrDocument.Pages.AddPages(multiPageTifFileName, 1, -1, new OcrProgressCallback(MyOcrProgressCallback)); 
 
         // Auto-recognize the zones in all the pages 
         _log.WriteLine("Auto-zoning"); 
         _log.WriteLine("********************************"); 
         ocrDocument.Pages.AutoZone(new OcrProgressCallback(MyOcrProgressCallback)); 
 
         // Recognize it and save it as PDF 
         _log.WriteLine("Recognizing"); 
         _log.WriteLine("********************************"); 
         ocrDocument.Pages.Recognize(new OcrProgressCallback(MyOcrProgressCallback)); 
         _log.WriteLine("Saving to PDF"); 
         _log.WriteLine("********************************"); 
         ocrDocument.Save(pdfFileName, DocumentFormat.Pdf, new OcrProgressCallback(MyOcrProgressCallback)); 
      } 
 
      // Shutdown the engine 
      // Note: calling Dispose will also automatically shutdown the engine if it has been started 
      ocrEngine.Shutdown(); 
   } 
 
   _log.WriteLine("********************************"); 
   _log.WriteLine("Complete"); 
   _log.Flush(); 
   _log.Close(); 
} 
// Text writer to save the log to 
private StreamWriter _log; 
 
private void MyOcrProgressCallback(IOcrProgressData data) 
{ 
   if (data.Percentage == 0) 
      _log.WriteLine("--------------------------"); 
 
   _log.WriteLine("Page:{0}({1}:{2}) {3}% Operation:{4}", 
      data.CurrentPageIndex.ToString("00"), 
      data.FirstPageIndex.ToString("00"), 
      data.LastPageIndex.ToString("00"), 
      data.Percentage.ToString("000"), 
      data.Operation); 
} 
 
static class LEAD_VARS 
{ 
   public const string ImagesDir = @"C:\LEADTOOLS23\Resources\Images"; 
   public const string OcrLEADRuntimeDir = @"C:\LEADTOOLS23\Bin\Common\OcrLEADRuntime"; 
} 
 
import java.io.File; 
import java.io.FileWriter; 
import java.io.IOException; 
 
import org.junit.*; 
import org.junit.runner.JUnitCore; 
import org.junit.runner.Result; 
import org.junit.runner.notification.Failure; 
import static org.junit.Assert.*; 
 
import leadtools.*; 
import leadtools.codecs.*; 
import leadtools.document.writer.*; 
import leadtools.ocr.*; 
 
 
// Text writer to save the log to 
private FileWriter _log; 
 
public void OcrProgressCallbackExample() throws IOException { 
   final String LEAD_VARS_IMAGES_DIR = "C:\\LEADTOOLS23\\Resources\\Images"; 
   final String OCR_LEAD_RUNTIME_DIR = "C:\\LEADTOOLS23\\Bin\\Common\\OcrLEADRuntime"; 
   String logFileName = combine(LEAD_VARS_IMAGES_DIR, "log.txt"); 
   String multiPageTifFileName = combine(LEAD_VARS_IMAGES_DIR, "Ocr1.tif"); 
   String pdfFileName = combine(LEAD_VARS_IMAGES_DIR, "Ocr1.pdf"); 
 
   // Create the log text writer 
   _log = new FileWriter(logFileName); 
 
   // Create an instance of the engine 
   OcrEngine ocrEngine = OcrEngineManager.createEngine(OcrEngineType.LEAD); 
   RasterCodecs codecs = new RasterCodecs(); 
 
   // Start the engine using default parameters 
   ocrEngine.startup(null, null, null, OCR_LEAD_RUNTIME_DIR); 
 
   // Create an OCR document 
   OcrDocument ocrDocument = ocrEngine.getDocumentManager().createDocument(); 
 
   // Add this image to the document 
   _log.write("Adding the pages\n"); 
   _log.write("********************************\n"); 
   RasterImage image = codecs.load(multiPageTifFileName, 16, CodecsLoadByteOrder.BGR, 1, -1); 
   ocrDocument.getPages().addPages(image, 1, -1, myOcrProgressCallback); 
 
   // Auto-recognize the zones in all the pages 
   _log.write("Auto-zoning\n"); 
   _log.write("********************************\n"); 
   ocrDocument.getPages().autoZone(myOcrProgressCallback); 
 
   // Recognize it and save it as PDF 
   _log.write("Recognizing\n"); 
   _log.write("********************************\n"); 
   ocrDocument.getPages().recognize(myOcrProgressCallback); 
   _log.write("Saving to PDF\n"); 
   _log.write("********************************\n"); 
   ocrDocument.save(pdfFileName, DocumentFormat.PDF, myOcrProgressCallback); 
 
   // Shutdown the engine 
   // Note: calling Dispose will also automatically shutdown the engine if it has 
   // been started 
   ocrEngine.shutdown(); 
 
   _log.write("********************************\n"); 
   _log.write("Complete\n"); 
   _log.flush(); 
   _log.close(); 
 
   assertTrue("Log file unsuccessfully created", new File(logFileName).exists()); 
   System.out.println("output file successfully created"); 
} 
 
OcrProgressListener myOcrProgressCallback = new OcrProgressListener() { 
 
   @Override 
   public void onProgress(OcrProgressData data) { 
      if (data.getPercentage() == 0) { 
         try { 
            _log.write("--------------------------\n"); 
         } catch (IOException e) { 
            e.printStackTrace(); 
         } 
      } 
 
      try { 
         _log.write("Page:" + data.getCurrentPageIndex() + "(" + data.getFirstPageIndex() + ":" 
               + data.getLastPageIndex() + ") " + data.getPercentage() + "% Operation:" + data.getOperation() 
               + "\n"); 
      } catch (IOException e) { 
         e.printStackTrace(); 
      } 
   } 
 
}; 
Requirements

Target Platforms

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

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