public event EventHandler<OcrAutoRecognizeJobOperationEventArgs> JobOperation
- (void)autoRecognizeManager:(LTOcrAutoRecognizeManager *)manager willRunOperation:(LTOcrAutoRecognizeJobOperationEventArgs *)operation
- (void)autoRecognizeManager:(LTOcrAutoRecognizeManager*)manager didRunOperation:(LTOcrAutoRecognizeJobOperationEventArgs*)operation
synchronized public void addJobOperationListener(OcrAutoRecognizeJobOperationListener listener)
synchronized public void removeJobOperationListener(OcrAutoRecognizeJobOperationListener listener)
event EventHandler<OcrAutoRecognizeJobOperationEventArgs^>^ JobOperation
def JobOperation(sender,e): # sender: IOcrAutoRecognizeManager e: OcrAutoRecognizeJobOperationEventArgs
The event handler receives an argument of type OcrAutoRecognizeJobOperationEventArgs containing data related to this event. The following OcrAutoRecognizeJobOperationEventArgs properties provide information specific to this event.
Property | Description |
---|---|
Document | Gets the OCR document being used in the current operation. |
This event will occur when Run, RunJob or RunJobAsync is called.
You can use this event to get information on the current operation (creating an OCR document, loading a page, zoning, recognizing, saving, etc.).
using Leadtools;
using Leadtools.Codecs;
using Leadtools.Ocr;
using Leadtools.Document.Writer;
using Leadtools.Forms.Common;
using Leadtools.WinForms;
public void JobOperationExample()
{
string imageFileName = Path.Combine(LEAD_VARS.ImagesDir, "Ocr1.tif");
string documentFileName = Path.Combine(LEAD_VARS.ImagesDir, "JobOperation.pdf");
using (IOcrEngine ocrEngine = OcrEngineManager.CreateEngine(OcrEngineType.LEAD))
{
ocrEngine.Startup(null, null, null, LEAD_VARS.OcrLEADRuntimeDir);
IOcrAutoRecognizeManager autoRecognizeManager = ocrEngine.AutoRecognizeManager;
autoRecognizeManager.JobOperation += new EventHandler<OcrAutoRecognizeJobOperationEventArgs>(autoRecognizeManager_JobOperation);
IOcrAutoRecognizeJob job = autoRecognizeManager.CreateJob(new OcrAutoRecognizeJobData(imageFileName, DocumentFormat.Pdf, documentFileName));
autoRecognizeManager.RunJob(job);
autoRecognizeManager.JobOperation -= new EventHandler<OcrAutoRecognizeJobOperationEventArgs>(autoRecognizeManager_JobOperation);
}
}
private static void autoRecognizeManager_JobOperation(object sender, OcrAutoRecognizeJobOperationEventArgs e)
{
// We did not pass a zone to the job, so the engine will attempt to do AutoZone unless we
// add any zone to the input document.
// We can also check for e.PostOperation equals to true and manipulate the zones
// found the engine at this point
// Add a graphics zone.
// If you comment out this code, the result PDF will contain text, but since we will be adding a zone here,
// the engine will not auto-zone the document for us. Also, since the zone we are adding is
// graphics that takes up the whole page, the result PDF will contain a raster image and no text.
if (!e.PostOperation && e.ImagePageNumber == 1)
{
OcrZone ocrZone = new OcrZone();
ocrZone.ZoneType = OcrZoneType.Graphic;
ocrZone.Bounds = new LeadRect(0, 0, e.Page.Width, e.Page.Height);
e.Page.Zones.Add(ocrZone);
}
}
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 OcrAutoRecognizeManagerJobOperationExample() {
String LEAD_VARS_ImagesDir = "C:\\LEADTOOLS23\\Resources\\Images";
String LEAD_VARS_OcrLEADRuntimeDir = "C:\\LEADTOOLS23\\Bin\\Common\\OcrLEADRuntime";
String imageFileName = combine(LEAD_VARS_ImagesDir, "Ocr1.tif");
String documentFileName = combine(LEAD_VARS_ImagesDir, "JobOperation.pdf");
OcrEngine ocrEngine = OcrEngineManager.createEngine(OcrEngineType.LEAD);
ocrEngine.startup(null, null, null, LEAD_VARS_OcrLEADRuntimeDir);
OcrAutoRecognizeManager autoRecognizeManager = ocrEngine.getAutoRecognizeManager();
autoRecognizeManager.addJobOperationListener(autoRecognizeManager_JobOperation);
OcrAutoRecognizeJob job = autoRecognizeManager
.createJob(new OcrAutoRecognizeJobData(imageFileName, DocumentFormat.PDF, documentFileName));
autoRecognizeManager.runJob(job);
autoRecognizeManager.removeJobOperationListener(autoRecognizeManager_JobOperation);
ocrEngine.dispose();
}
OcrAutoRecognizeJobOperationListener autoRecognizeManager_JobOperation=new OcrAutoRecognizeJobOperationListener(){
@Override public void onOperation(OcrAutoRecognizeJobOperationEvent e){
// We did not pass a zone to the job, so the engine will attempt to do AutoZone
// unless we
// add any zone to the input document.
// We can also check for e.PostOperation equals to true and manipulate the zones
// found the engine at this point
// Add a graphics zone.
// If you comment out this code, the result PDF will contain text, but since we
// will be adding a zone here,
// the engine will not auto-zone the document for us. Also, since the zone we
// are adding is
// graphics that takes up the whole page, the result PDF will contain a raster
// image and no text.
if (!e.isPostOperation()&&e.getImagePageNumber()==1) {
OcrZone ocrZone=new OcrZone();
ocrZone.setZoneType(OcrZoneType.GRAPHIC);
ocrZone.setBounds(new LeadRect(0,0,e.getPage().getWidth(),e.getPage().getHeight()));e.getPage().getZones().add(ocrZone);
}
}
};
Help Collections
Raster .NET | C API | C++ Class Library | HTML5 JavaScript
Document .NET | C API | C++ Class Library | HTML5 JavaScript
Medical .NET | C API | C++ Class Library | HTML5 JavaScript
Medical Web Viewer .NET
Multimedia
Direct Show .NET | C API | Filters
Media Foundation .NET | C API | Transforms
Supported Platforms
.NET, Java, Android, and iOS/macOS Assemblies
Imaging, Medical, and Document
C API/C++ Class Libraries
Imaging, Medical, and Document
HTML5 JavaScript Libraries
Imaging, Medical, and Document
Your email has been sent to support! Someone should be in touch! If your matter is urgent please come back into chat.
Chat Hours:
Monday - Friday, 8:30am to 6pm ET
Thank you for your feedback!
Please fill out the form again to start a new chat.
All agents are currently offline.
Chat Hours:
Monday - Friday
8:30AM - 6PM EST
To contact us please fill out this form and we will contact you via email.