The RunJobAsync Method is available as an add-on to the LEADTOOLS Document and Medical Imaging toolkits.
- job
- The IOcrAutoRecognizeJob to run this parameter cannot be null (Nothing in Visual Basic). Use IOcrAutoRecognizeManager.CreateJob to create a job.
Visual Basic (Declaration) | |
---|---|
Sub RunJobAsync( _ ByVal job As IOcrAutoRecognizeJob _ ) |
Visual Basic (Usage) | Copy Code |
---|---|
Dim instance As IOcrAutoRecognizeManager Dim job As IOcrAutoRecognizeJob instance.RunJobAsync(job) |
C# | |
---|---|
void RunJobAsync( IOcrAutoRecognizeJob job ) |
C++/CLI | |
---|---|
void RunJobAsync( IOcrAutoRecognizeJob^ job ) |
Parameters
- job
- The IOcrAutoRecognizeJob to run this parameter cannot be null (Nothing in Visual Basic). Use IOcrAutoRecognizeManager.CreateJob to create a job.
This method will create an internal worker thread and return control immediatly to the called. When the job is completed, the IOcrAutoRecognizeJob.Errors member of job will contain any errors that might have occured during the recognition process. To get notification when the job is completed (whether successfully or with aborted due to errors or through user action), subscribe to the IOcrAutoRecognizeManager.JobCompleted events.
To run a job synchronously, use IOcrAutoRecognizeManager.RunJob.
To use this method, initialize a new OcrAutoRecognizeJobData object with the job's parameters (input image file name, pages, output document format, output document name, optional zones file name, etc.), then use IOcrAutoRecognizeManager.CreateJob to create the IOcrAutoRecognizeJob object passed as job to this method. Finally, call IOcrAutoRecognizeManager.RunJobAsync passing the IOcrAutoRecognizeJob object.
This method will perform the following operations:
-
The IOcrAutoRecognizeManager.JobStarted event is triggered.
-
Creates one ore more IOcrDocument object to store the pages into. The number of OCR documents created is dependant on MaximumThreadsPerJob. If this value is 0 (maximum CPUs/cores) or is greater than 1 and multiple threads is supported by this engine, then more than one document might be created to participate in the recognition process.
-
Loops through the pages specified in OcrAutoRecognizeJobData.FirstPageNumber and in OcrAutoRecognizeJobData.LastPageNumber in OcrAutoRecognizeJobData.ImageFileName and for each page:
The page is added to its document using IOcrPageCollection.AddPage.
If OcrAutoRecognizeJobData.ZonesFileName contains a valid multi-page zone file name and has an entry for the current page, then the zones are loaded with IOcrPage.LoadZones(fileName, pageNumber) and applied to the page. If OcrAutoRecognizeJobData.ZonesFileName is a null (Nothing in Visual Basic) reference or it does not contain an equivalant page number, auto-decomposing of the page is performed instead with IOcrPage.AutoZone.
IOcrPage.Recognize is called to get the OCR data of the page.
If multiple documents are used or current number of recognized pages is greater than the maximum specified in MaximumPagesBeforeLtd, then current recognition data is saved to a temporary LTD file and the OCR document is cleared.
-
When all pages are processed their saved to result file name specified in OcrAutoRecognizeJobData.DocumentFileName using the format specified OcrAutoRecognizeJobData.Format If LTD was used, the temporary file is converted to the final document using DocumentWriter.Convert and optionally DocumentWriter.AppendLtd.
-
All OCR documents and temporary files are deleted.
-
The IOcrAutoRecognizeManager.JobCompleted event is triggered.
-
You can use the IOcrAutoRecognizeManager.JobProgress event to show the operation progress or to abort it if threading is not used. For more information and an example, refer to Leadtools.Forms.Ocr.OcrProgressCallback.
-
You can use the IOcrAutoRecognizeManager.JobOperation event to get information regarding the current operation being performed. For more information and an example, refer to IOcrAutoRecognizeManager.JobOperation.
The IOcrAutoRecognizeManager interface also has the following options to use with this method:
Option | Description |
---|---|
MaximumPagesBeforeLtd |
Add support for converting a document with unlimited number of pages. An OCR recognition operation on a document that contains a large amount of pages (10 and more) might result in an out of memory error. All of the LEADTOOLS OCR engines supports saving the intermediate recognition results to a temporary LTD file (DocumentFormat.LTD). The result of subsequent pages will be appended to this temporary file. When all the pages of the document have been recognized, the engine will convert the temporary LTD file to the desired output format. The MaximumPagesBeforeLtd property defines the maximum number of pages processed as a whole. For example, if the original document has 20 pages and the value of this property is 8, the engine will recognize the first 8 pages and saves the result to a temporary file, recognizes the second 8 pages and append the results, and finally, recognize the last 4 pages and convert the temporary documentto the final format. |
PreprocessPageCommands |
Holds an array of OcrAutoPreprocessPageCommand items to control what auto-preprocess operation to perform on each page document prior to recognition. |
MaximumThreadsPerJob |
Maximum number of threads to use per job. You can instruct IOcrAutoRecognizeManager to use all available machine CPUs/cores when recognizing a document. This will greatly reduce the time required to finish the OCR operation. |
JobErrorMode |
Ability to resume on none critical errors. For example, if a source document has a page that could not be recognized. The offending page will be added to the final document as a graphics images and recognition will continue to the next page. |
IOcrAutoRecognizeManager.JobStarted, IOcrAutoRecognizeManager.JobProgress, IOcrAutoRecognizeManager.JobOperation and IOcrAutoRecognizeManager.JobCompleted events |
Events to track when both synchronous and asynchronous jobs has started, being run and completed. |
AbortAllJobs |
Aborts all running and pending jobs. |
EnableTrace |
Output debug messages to the standard .NET trace listeners. |
Target Platforms: Microsoft .NET Framework 2.0, Windows 2000, Windows XP, Windows Server 2003 family, Windows Server 2008 family, Windows Vista, Windows 7