StatusJobDataRunner has support for document conversion, along with status update. This feature utilizes LEADTOOLS caching to:
The main class for running a conversion with status is StatusJobDataRunner that uses instances of StatusJobData for each conversion. A simple workflow of an application using the status job converter is as follows:
// Create a new status job data and set its options
var jobData = new lt.Document.DocumentConverterJobData();
jobData.documentFormat = lt.Document.Writer.DocumentFormat.pdf;
// Run the conversion on an existing document in the cache
// sourceDocumentId is the ID of an existing document in the cache
This workflow performs the conversion job but does not allow status information about the job to be obtained. To do that, modify the code as specified in the StatusJobDataRunner example.
When conversion starts, the runner will create a new cache item with Region/Key set to userToken/jobToken respectively, and the value set to a copy of the StatusJobData input object. As the job progresses, the runner will update this item in the cache with the latest status and timestamps. The application can use queryConvertJobStatus at any time to get the latest version of StatusJobData from the cache with updated values of the conversion status and any errors that might have occurred. The value of isCompleted is true when the runner has completed the conversion.
StatusJobData contains various members that can be organized into the following sections:
|userToken and jobToken
|Unique identifiers for user and the job. These are used as the cache region and key to create a unique identifier for the job.
|Any user-defined data associated with the job.
|Latest status of the job, whether it has started, completed, or aborted.
|Extra information on the last job status.
|Determines whether the job has been completed.
|Allows the user to abort a running job.
|jobStartedTimestamp, jobCompletedTimestamp, jobStatusTimestamp, queryJobStatusTimestamp
|Timestamps of various job operations.
|Holds any error messages occurred during the conversion.
userToken and jobToken must be specified by the application (or set automatically by the StatusJobDataRunner class), and combining them should create a unique string. Internally, the runner will use userToken and jobToken as the Region and Key of a cache item added to the cache.
jobStatusMessage will contain extra information about the last job status.
isCompleted will be false as long as the runner is performing the conversion. It is set to true when the job finishes (successfully or not: the status will contain Success or Aborted, depending on the result of the conversion). In case of errors, errorMessages contains helpful hints and messages for one or more errors that occurred.
The various timestamps can be queried to check the health of the conversion and whether it is still performing correctly.
|The ID of the source document to be converted.
|Optional first and last page numbers of the document to be converted.
These members must be initialized to the information about the input document in the cache to be converted.
|Optional ID to use for the output document.
|Uploaded URI to use for the output document.
The resulting output document from the conversion is uploaded to the cache. These members define how to store the document.
|documentFormat, rasterImageFormat, rasterImageBitsPerPixel
|Format to use for the output document.
|Optional job name.
|Annotation output mode.
Finally, this section specifies the output document type and annotation mode to use.
For a full example, refer to StatusJobDataRunner.