Knowledge Base

Article ID: 1285 | Category: Project Setup | Type: FAQ | Last Modified: 8/20/2013

Event Handler Script

Available downloads


How can I use event handlers scripts in my FlexiCapture project? What is the difference between event handlers and other script types? How to create event handlers scripts?


FlexiCapture 10 allows you to create event handlers for batch, document, and field events. This means that you can write scripts to be called for an element (batch, document, or field) if a certain event takes place. Below you will find a complete list of events for which scripts can be created.

The main difference between event handlers and other script types used to customize document processing in FlexiCapture 10 is that event handlers are not associated with any particular processing stage. The script of an event handler is executed whenever its corresponding event takes place. For example, if you create a script for a Before page delete event, it will be executed both if a page is deleted by an operator at the Verification stage, and if a page is deleted at the Exceptions stage. Therefore, event handler scripts are useful when you need certain actions to be triggered by certain events.

Using event handler scripts, you can set up complicated processing scenarios. For example, you can use a Field verification request script to specify which fields will not be submitted to the context verification. Or you can use a Before matching script to control which sections or Document Definitions will be matched on each subsequent page and specify the matching order. With this script you can accelerate matching the Document Definition if sections to be matched are known in advance. For example:

The Before matching script allows you to disable recognition of document after a Document Definition is matched. For this, set the IMatchingInfo.NeedRecognition parameter to false. It can be useful if field values are supposed to be entered manually. It is also possible to mark the page as an annex page which does not need recognition. For this, it is necessary to specify an empty list of sections and set the IMatchingInfo.ForceMatch parameter to true.

How to create event handlers scripts

Event handlers are stored in the batch type.

To set up event handlers, open the Batch Type Properties dialog box and click the Event Handlers tab. For the Unknown batch type, event handlers can be set up on the Event Handlers tab of the Project Properties dialog box. To add a script for a particular event, select the event in the list and click Edit Script… button.

If a procedure is to be used in more than one event handler, you can write it to the global Events module to avoid writing duplicate code fragments. The Events module is available from the drop-down list of the toolbar in the script editor window.

You can use methods and classes of external assemblies in you event handler scripts. To use external methods and classes, attach them on the .Net References tab of the Batch Type Properties dialog box (or the Project Properties dialog box in the case of the Unknown batch type). For more information about .Net support in FlexiCapture 10 see the article.

In FlexiCapture 10, you can create scripts for the following events:

1)       Batch events

2)       Document events

3)       Field event

For a detailed description of each event, please refer to Help → Appendix → Using scripts in ABBYY FlexiCapture 10 → Scripts for customizing processing → Types of scripts → Event handlers.

It should be noted that internal fields of batch documents and pages are unavailable from most of these event handlers. Therefore, event handler scripts cannot be used to modify these data. If you need to modify it, this can be done at a custom stage using processing scripts. However, internal fields are available for Before pages move and After document state changed events. Scripts for these two events can change internal data (i.e. fields and properties) of an entire document. This may be necessary if a document contains calculated fields.

In the EventHandlers.rar archive you can find 2 samples of using event handlers scripts:

534 people think this is helpful.
Was this information helpful to you?