Value | Member | Description |
---|---|---|
0 | Other | Other operation, such as unexpected and unrecoverable errors. |
1 | CreateDocument | The IOcrAutoRecognizeManager is creating a document with IOcrDocumentManager.CreateDocument. |
2 | PrepareDocument | Preparing the IOcrDocument, in certain situations, by clearing all the pages inside it. |
3 | LoadPage | Loading the image of a page using RasterCodecs.Load. The page is then created using IOcrEngine.CreatePage. |
4 | PreprocessPage | Preprocessing a page using IOcrPage.AutoPreprocess. |
5 | ZonePage | Zoning a page using IOcrPage.AutoZone or IOcrPage.LoadZone.Note that when using the IOcrAutoRecognizeManager.JobOperation event, you can use this operation to zone the page manually as shown in the OcrAutoRecognizeJobOperationEventArgs example. |
6 | RecognizePage | Recognizing a page using IOcrPage.Recognize. |
7 | SavePage | Saving a page using IOcrDocument.Save. |
8 | AppendLtd | Appending multiple LTD's using DocumentWriter.AppendLtd. |
9 | SaveDocument | Saving a document using IOcrDocument.Save. |
10 | ConvertDocument | Converting a document to its final format using DocumentWriter.Convert. |
Used as type for the following properties:
The OcrAutoRecognizeManagerJobError.Operation property to indicate the operation that cause the error.
You can set IOcrAutoRecognizeManager.JobErrorMode to OcrAutoRecognizeManagerJobErrorMode.Continue to log and continue when a none critical error occurs during the recognition process. The following errors are considered unrecoverable and the recognition will fail regardless on the current error mode: Other, CreateDocument, PrepareDocument, LoadPage, SavePage, AppendLtd, SaveDocument and Convert.
The OcrAutoRecognizeJobOperationEventArgs.Operation property to indicate the operation being run.
IOcrAutoRecognizeManager allows you to modify the raster image, OCR page or OCR document during some parts of the operation. Refer to OcrAutoRecognizeJobOperationEventArgs.PageImage for more information an example.
The OcrAutoRecognizeJobOperationEventArgs.Status property can be set to OcrAutoRecognizeJobStatus.Abort inside the event handler to abort the current operation. Aborting the operation will cause the whole job to be canceled. The only exception is with LoadPage. If Status is set to Abort, then the page will be skipped and not added to the final document. The following code performs custom processing (in this example, blank page detection) to skip specific pages from being added to the final document:
// Our IOcrAutoRecognizeManager.JobOperation event handler
EventHandler<OcrAutoRecognizeJobOperationEventArgs> jobOperation = (object sender, OcrAutoRecognizeJobOperationEventArgs e) =>
{
if (e.Operation == OcrAutoRecognizeManagerJobOperation.LoadPage && !e.PostOperation)
{
// IOcrPage has been created with an image loaded, check if it is empty
// Get the image
using (RasterImage image = e.Page.GetRasterImage(OcrPageType.Original))
{
// Run the blank bage detector command
var blankPageDetector = new BlankPageDetectorCommand(BlankPageDetectorCommandFlags.None, 0, 0, 0, 0);
blankPageDetector.Run(image);
if (blankPageDetector.IsBlank)
{
// The image is blank, inform the OCR auto recognize manager to skip it
e.Status = OcrAutoRecognizeManagerJobStatus.Abort;
}
}
}
};
IOcrAutoRecognizeManager ocrAutoRecognizeManager = ocrEngine.AutoRecognizeManager;
// Create the job
var jobData = new OcrAutoRecognizeJobData(inputFile, DocumentFormat.Pdf, outputFile);
IOcrAutoRecognizeJob ocrJob = ocrAutoRecognizeManager.CreateJob(jobData);
// Add our event
ocrAutoRecognizeManager.JobOperation += jobOperation;
// Run the job
ocrAutoRecognizeManager.RunJob(ocrJob);
ocrAutoRecognizeManager.JobOperation -= jobOperation;