Assembling Applications
For assembling applications instant workflows are the best choice since they can be fully customized in contrast to file or predefined workflows. Instant workflows are created according to the following scenario:
IWFHandler.SetTempParam
...
IWFHandler.SetTempParam
IWFHandler.CreateWF
IWFHandler.FinalizeWF (optional; if not called, then it is called by StartWorkflow )
IWFHandler.StartWorkflow
Once the desired parameters are set using SetTempParam method, the CreateWf-FinalizeWF-StartWorkflow block will run 'n' times; the above block cannot be disassembled, it must be repeated as many times as many workflows should be created.
CreateWF Block
Using IWFTYPE Members
The instant workflow types are listed in the IWFTYPE Enumeration topic. Most of these consist of one-step predefined workflows (eg. IWFT_LOADIMAGE, IWFT_SCANIMAGE, IWFT_RECOGNIZE, etc.), but there are also multi (2-3) step ones (eg. IWFT_AUTOPROCLOAD, IWFT_AUTOPROCSCAN).
These are the specific steps in the specific workflow types:
IWFTYPE | WFStepFlag Equivalents | Description |
IWFT_AUTOPROCLOAD |
|
|
IWFT_AUTOPROCSCAN |
|
|
IWFT_QUICKCONVLOAD |
|
|
IWFT_RECEXPORT |
|
|
There are essential differences between workflow types with similar functions that influence their operation and therefore need to be considered before utilizing them:
IWFT_AUTOPROCLOAD vs. IWFT_AUTOPROCSCAN: both are the same 3-step workflows, but IWFT_AUTOPROCSCAN starts with scanning; loading is not involved.
IWFT_AUTOPROCLOAD vs. IWFT_QUICKCONVLOAD: IWFT_AUTOPROCLOAD has three steps, whereas IWFT_QUICKCONVLOAD has only two.
IWFT_RECEXPORT vs. IWFT_QUICKCONV: IWFT_RECEXPORT has two steps, whereas IWFT_QUICKCONV has only one.
Using WFStepFlag Members
The fundamental difference between IWFTYPE and WFStepFlag members is that WFStepFlag consists of strictly one-step flags.
When creating any kind of workflow via using the WFStepFlag members, it is recommended to consider that one flag can be used only once. Also, at the end of each created workflow the IWFT_WFS_DIRECT flag must be included, otherwise the created workflow will be taken as a predefined one, which might result in a workflow functioning totally differently from what is expected (eg. SAVEOPD function instead of EXPORTDOC function).
FinalizeWF Block
It is actually the FinalizeWF method where the workflow itself is created; it presents a last option for the programmer to review the steps and make any necessary changes to them: deleting, adding, modifying steps. It is an optional step, if not called by the programmer, then it will be called by the StartWorkflow method.
The WFDescInfo interface contains the workflow itself. Additional workflow contents can be added via WFDescInfo methods (AddWFObject, AddWFStep); usually pages can be added.
When starting workflow execution with the StartWorkflow method, the following precautions should be taken for proper functionality:
The SyncMode should be set to True: this results in the function call not returning until the workflow is processed. In case of writing a UI application, the preferred SyncMode setting is asynchronous, due to which several threads can run in the application at the same time. In case of programming a console application, the preferred SyncMode setting is synchronous, allowing only one thread to be run at a time. In this way, the application will only start running the next thread once the previous one has executed properly.
The processing modes of the workflows can be set according to the members of the WFPROCMODE Enumeration. It must always be set to WPM_REAL_MODE. In the next versions this might be deprecated!
Once a workflow has started, it will run and end by all means, irrespective of whether it is successful or not in terms of the desired output generated. The document must not be modified and the PauseWorkflow method should not be called in synchronous mode processing.
Once the WorkflowEnd event is fired, it is not recommended to start a new workflow from the current thread for avoiding a deadlock that would result from the last thread being unable to terminate. A new workflow should rather be started from a different thread or the main thread.