←Select platform

JobProgress Event

Summary
Occurs when a job is being run to provide progress status and ability to abort.
Syntax
C#
Objective-C
C++/CLI
Python
public event EventHandler<OcrAutoRecognizeJobProgressEventArgs> JobProgress 
- (void)autoRecognizeManager:(LTOcrAutoRecognizeManager *)manager progress:(LTOcrProgressData *)progressData 
event EventHandler<OcrAutoRecognizeJobProgressEventArgs^>^ JobProgress 
def JobProgress(sender,e): # sender: IOcrAutoRecognizeManager e: OcrAutoRecognizeJobProgressEventArgs 
Event Data

The event handler receives an argument of type OcrAutoRecognizeJobProgressEventArgs containing data related to this event. The following OcrAutoRecognizeJobProgressEventArgs properties provide information specific to this event.

PropertyDescription
Data Gets the event progress data.
Remarks

Note, this event will not trigger if multiple threads are used on the same document (the value of MaximumThreadsPerJob is anything else but 1).

This event will occur when Run, RunJob or RunJobAsync is called.

For more information, refer to OcrAutoRecognizeJobProgressEventArgs and OcrProgressCallback.

Example
C#
Java
using Leadtools; 
using Leadtools.Codecs; 
using Leadtools.Ocr; 
using Leadtools.Document.Writer; 
using Leadtools.Forms.Common; 
using Leadtools.WinForms; 
 
public void JobProgressExample() 
{ 
   string tifFileName = Path.Combine(LEAD_VARS.ImagesDir, "Ocr1.tif"); 
   string pdfFileName = Path.Combine(LEAD_VARS.ImagesDir, "Ocr1.pdf"); 
 
   // Create an instance of the engine 
   using (IOcrEngine ocrEngine = OcrEngineManager.CreateEngine(OcrEngineType.LEAD)) 
   { 
      // Start the engine using default parameters 
      Console.WriteLine("Starting up the engine..."); 
      ocrEngine.Startup(null, null, null, LEAD_VARS.OcrLEADRuntimeDir); 
 
      IOcrAutoRecognizeManager ocrAutoRecognizeManager = ocrEngine.AutoRecognizeManager; 
 
      // Run the job in 1 thread 
      ocrAutoRecognizeManager.MaximumThreadsPerJob = 1; 
 
      // Create the job 
      OcrAutoRecognizeJobData ocrJobData = new OcrAutoRecognizeJobData(tifFileName, DocumentFormat.Pdf, pdfFileName); 
      ocrJobData.JobName = "MyJob"; 
      IOcrAutoRecognizeJob ocrJob = ocrAutoRecognizeManager.CreateJob(ocrJobData); 
 
      // Subscribe to the JobProgress event 
      ocrAutoRecognizeManager.JobProgress += new EventHandler<OcrAutoRecognizeJobProgressEventArgs>(ocrAutoRecognizeManager_JobProgress); 
 
      // Run the job 
      ocrAutoRecognizeManager.RunJob(ocrJob); 
 
      // Unsubscribe to the JobProgress event 
      ocrAutoRecognizeManager.JobProgress -= new EventHandler<OcrAutoRecognizeJobProgressEventArgs>(ocrAutoRecognizeManager_JobProgress); 
   } 
} 
 
private static void ocrAutoRecognizeManager_JobProgress(object sender, OcrAutoRecognizeJobProgressEventArgs e) 
{ 
   Console.WriteLine(string.Format("Job: {0} - Page: {1}:{2} - {3} - {4}%", 
      e.Job.JobData.JobName, e.Data.CurrentPageIndex + 1, e.Data.LastPageIndex + 1, e.Data.Operation, e.Data.Percentage)); 
} 
 
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.FileNotFoundException; 
import java.io.FileWriter; 
import java.io.FilenameFilter; 
import java.io.IOException; 
import java.nio.file.Files; 
import java.nio.file.Path; 
import java.nio.file.Paths; 
import java.util.ArrayList; 
import java.util.concurrent.ExecutorService; 
import java.util.concurrent.Executors; 
import java.util.concurrent.atomic.AtomicInteger; 
 
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.document.writer.*; 
import leadtools.internal.AutoResetEvent; 
import leadtools.ocr.*; 
 
 
public void OcrAutoRecognizeManagerJobProgressExample() { 
   String LEAD_VARS_ImagesDir = "C:\\LEADTOOLS23\\Resources\\Images"; 
   String LEAD_VARS_OcrLEADRuntimeDir = "C:\\LEADTOOLS23\\Bin\\Common\\OcrLEADRuntime"; 
   String tifFileName = combine(LEAD_VARS_ImagesDir, "Ocr1.tif"); 
   String pdfFileName = combine(LEAD_VARS_ImagesDir, "Ocr1.pdf"); 
 
   // Create an instance of the engine 
   OcrEngine ocrEngine = OcrEngineManager.createEngine(OcrEngineType.LEAD); 
   // Start the engine using default parameters 
   System.out.println("Starting up the engine..."); 
   ocrEngine.startup(null, null, null, LEAD_VARS_OcrLEADRuntimeDir); 
   assertTrue("OCR Engine unsuccessfully started", ocrEngine.isStarted()); 
 
   OcrAutoRecognizeManager ocrAutoRecognizeManager = ocrEngine.getAutoRecognizeManager(); 
 
   // Run the job in 1 thread 
   ocrAutoRecognizeManager.setMaximumThreadsPerJob(1); 
 
   // Create the job 
   OcrAutoRecognizeJobData ocrJobData = new OcrAutoRecognizeJobData(tifFileName, DocumentFormat.PDF, pdfFileName); 
   ocrJobData.setJobName("MyJob"); 
   OcrAutoRecognizeJob ocrJob = ocrAutoRecognizeManager.createJob(ocrJobData); 
 
   // Subscribe to the JobProgress event 
   ocrAutoRecognizeManager.addJobOperationListener(ocrAutoRecognizeManager_JobProgress); 
   // Run the job 
   ocrAutoRecognizeManager.runJob(ocrJob); 
 
   // Unsubscribe to the JobProgress event 
   ocrAutoRecognizeManager.removeJobOperationListener(ocrAutoRecognizeManager_JobProgress); 
   ocrEngine.dispose(); 
} 
 
OcrAutoRecognizeJobOperationListener ocrAutoRecognizeManager_JobProgress=new OcrAutoRecognizeJobOperationListener(){ 
 
   @Override public void onOperation(OcrAutoRecognizeJobOperationEvent e){ 
      int percentage = (int)((((double) e.getImagePageNumber() + 1) / (e.getJob().getJobData().getLastPageNumber() + 1)) * 100); 
      System.out.println( 
         "Job: " + e.getJob().getJobData().getJobName() +  
         " - Page: " + e.getImagePageNumber() + 1 +  
         ":" + e.getJob().getJobData().getLastPageNumber() + 1 +  
         " - " + e.getOperation() +  
         " - " + percentage + "%"); 
   } 
 
}; 
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.