Customizing workflows

Most of the tasks can be performed with a combination of built-in job items. Built-in job items have general functions, they perform the tasks requested by the workflow XML, but do not make decisions. The number of built-in job items is continuously increasing, moreover, developers can add custom job items and tools (wizards) with the provided C# templates.

Custom job items usually perform specific tasks, for example, to decide the next step according to the state of a document. Custom job items can be integrated both design side and processing side.

Processing side

Job items in the processing side are called worker job item.

Each job item node has a clsid attribute. The OCRServer creates the job item during the job item tree creation according to the clsid attribute. If the clsid is not recognized, the job item is treated as a custom job item.

Custom job items are usually registered COM objects, implementing a specific interface. The native description of the interface is located in the IOCRJobItem within the type library embedded into the OCRServer.exe file.

OCRServer uses the XML snippet to identify a custom job item:

<JobItem>
…
</JobItem>

Attributes of the JobItem XML element

Attribute Description

clsid

This mandatory attribute uses the following format:

clsid="{01234567-8901-2345-6789-012345678901}"

If OCRServer cannot identify the job item, then instantiates it by calling the CoCreateInstance COM function.

codebase

This optional attribute specifies the full path and filename to the .dll containing the job item.

  • For job items developed in C++, OCRServer calls the DllGetClassObject function to instantiate the job item. In this case, the COM registration is not required.

  • For job items developed in .Net Framework assembly, you can specify the codebase attribute, but this alone will not instantiate the job item.

class

This optional attribute specifies the class name for the implementation.

  • For job items developed in .NET assembly, this is the name of the class implementing the job item.
  • For job items developed in .NET Framework assembly, OCRServer instantiates the job item based on the codebase and class attributes, by calling the _AppDomain::CreateInstance function. In this case, the COM registration is not required.

  • For job items developed in .NET Core assembly, you can specify the class attribute, but this alone will not instantiate the job item.

assembly

This optional attribute specifies the assembly name for the implementation.

  • For job items developed in .NET assembly, this is the name of the assembly. The assemlby file should be placed beside the OCRServer.exe file, in the same folder.
  • For job items developed in .NET Framework assembly, OCRServer instantiates the job item based on the assembly and class attributes, by calling the _AppDomain::CreateInstanceFrom function. In this case, the COM registration is not required.

  • For job items developed in .NET Core assembly, OCRServer instantiates the job item based on the assembly and class attributes, by calling the _ICLRRuntimeHost4::CreateDelegate function. The implementing class needs to have the following static function:
    public static int CreateInstance([Out, MarshalAs(UnmanagedType.CustomMarshaler,
    MarshalTypeRef = typeof(JobItemMarshaler))] out JobItem value)

OCRServer instantiates the custom job item, and then gets the related interface. If instantiation is successful, the custom job items are handled the same way as built-in job items. It means the custom job item receives the following items:

  • The Engine object of the IproPlus interface,

  • The Document object if it exists,

  • The XML snippet related to the job item.

Native custom job items can be also written based on the type library.

.NET developers can use the OmniPageCSDK.IproPlus.JobItem.dll assembly to provide the basic functionalities to a custom job item.

Developers can write any codes in the Run method of the custom job item.

Design side

Job items in the design side are called design job item.

Workflow XML Designer can integrate the custom job item designer. This way custom job item snippets can be generated automatically with the support of UI.

Only .NET Framework is supported for design side integration. .NET developers can use the OmniPageCSDK.IproPlus.JobDesign.dll assembly to provide the basic functionalities to a custom job item.

General notes

  • A project can contain any number of worker job items and design job items.

  • Worker job items and design job items can be added to the project by selecting Add > New Item in Visual Studio. Templates are loacted in Installed > Visual C# Items > OmniPage.

  • Each design job items in an assembly have to be integrated separately by selecting the design job item in Workflow XML Designer > Custom Job Items > Class.

  • Worker job items and design job items can be in different assemblies.

  • If the assembly is not signed, a warning is created during the build.

  • Do not use "Register for COM interop" option, the sample project does the registration in PostBuildEvent. It does not appear on "Project properties" page, as registration is platform specific, and the Visual Studio does not handle it. To view the PostBuildEvent command, unload the project, and select "Edit" option.

  • RegAsm is platform specific. Make sure to use the proper platform during the installation of the assembly.