←Select platform

JobProgress Event

Summary
Occurs when a job is being run to provide progress status and ability to abort.
Syntax
C#
VB
Objective-C
C++
public event EventHandler<OcrAutoRecognizeJobProgressEventArgs> JobProgress 
Event JobProgress As EventHandler(Of OcrAutoRecognizeJobProgressEventArgs) 
- (void)autoRecognizeManager:(LTOcrAutoRecognizeManager *)manager progress:(LTOcrProgressData *)progressData 
event EventHandler<OcrAutoRecognizeJobProgressEventArgs^>^ JobProgress 
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#
VB
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:\LEADTOOLS21\Resources\Images"; 
   public const string OcrLEADRuntimeDir = @"C:\LEADTOOLS21\Bin\Common\OcrLEADRuntime"; 
} 
Imports Leadtools 
Imports Leadtools.Codecs 
Imports Leadtools.Ocr 
Imports Leadtools.Document.Writer 
Imports Leadtools.Forms.Common 
Imports Leadtools.WinForms 
 
Public Sub JobProgressExample() 
   Dim tifFileName As String = Path.Combine(LEAD_VARS.ImagesDir, "Ocr1.tif") 
   Dim pdfFileName As String = Path.Combine(LEAD_VARS.ImagesDir, "Ocr1.pdf") 
 
   ' Create an instance of the engine 
   Using ocrEngine As IOcrEngine = OcrEngineManager.CreateEngine(OcrEngineType.LEAD) 
      ' Start the engine using default parameters 
      Console.WriteLine("Starting up the engine...") 
      ocrEngine.Startup(Nothing, Nothing, Nothing, LEAD_VARS.OcrLEADRuntimeDir) 
 
      Dim ocrAutoRecognizeManager As IOcrAutoRecognizeManager = ocrEngine.AutoRecognizeManager 
 
      ' Run the job in 1 thread 
      ocrAutoRecognizeManager.MaximumThreadsPerJob = 1 
 
      ' Create the job 
      Dim ocrJobData As New OcrAutoRecognizeJobData(tifFileName, DocumentFormat.Pdf, pdfFileName) 
      ocrJobData.JobName = "MyJob" 
      Dim ocrJob As IOcrAutoRecognizeJob = ocrAutoRecognizeManager.CreateJob(ocrJobData) 
 
      ' Subscribe to the JobProgress event 
      AddHandler ocrAutoRecognizeManager.JobProgress, AddressOf ocrAutoRecognizeManager_JobProgress 
      ' Run the job 
      ocrAutoRecognizeManager.RunJob(ocrJob) 
 
      ' Unsubscribe to the JobProgress event 
      RemoveHandler ocrAutoRecognizeManager.JobProgress, AddressOf ocrAutoRecognizeManager_JobProgress 
   End Using 
End Sub 
 
Private Shared Sub ocrAutoRecognizeManager_JobProgress(sender As Object, e As OcrAutoRecognizeJobProgressEventArgs) 
   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)) 
End Sub 
 
Public NotInheritable Class LEAD_VARS 
   Public Const ImagesDir As String = "C:\LEADTOOLS21\Resources\Images" 
   Public Const OcrLEADRuntimeDir As String = "C:\LEADTOOLS21\Bin\Common\OcrLEADRuntime" 
End Class 
Requirements

Target Platforms

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

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