Skip to main content
FlexiLayout blocks correspond to fields on the documents from which data must be captured. A block specifies the type of data that the field can contain and the coordinates of the image area where the field is likely to be found. The blocks branch is marked with Tree block icon in the FlexiLayout tree.

FlexiLayout block types

ABBYY FlexiLayout Studio supports the following block types: Expanding the regions of text blocks can improve recognition quality. To expand a region, double-click the Blocks element to open its Properties dialog box, and then specify the vertical and horizontal values for the Blocks result region inflate property. Blocks for which no image area is specified in at least one layout alternative have an empty square in the top right corner of the icon: Undefined block icon. If only one FlexiLayout is selected (via the Select Layout item on the element’s shortcut menu, via the same item in the FlexiLayout section, or via the Select Alternative Layout item on the FlexiLayout’s shortcut menu), the program checks for the image area only in this FlexiLayout.
Data from the blocks are extracted in a data capture application such as ABBYY FlexiCapture.

Block properties

A block has the following properties: The Instance sort order property has the following values: With In order of finding, if you specify additional conditions for instances, hypotheses are generated in the user-defined order. If you need an order different from the standard order used by the program, you can specify it by means of additional conditions. The following properties specify the area on the image from which data must be extracted.

For Layout

Selects the layout alternative where the search area is specified.

Source element

Specifies an area on the image that is identical to the region of the element used to find the block on the image. When the FlexiLayout is applied to the image, the program searches for the object (or objects) described by the element. The data is captured from these objects. For a repeating group, you can select either one of the instances or use all the instances (AllInstances). For more information, see Use instances of a Repeating Group as reference, excluded, or source elements.

Expression

Sets an area on the image that does not coincide with any of the element regions. For example, you can merge the regions of some elements and the space among them into one block, expand the region of an element by a certain value, or specify the coordinates of the block without relying on any elements. In this case, the region of the block can be described in the FlexiLayout language.
The region of a block is continuous. This means that if you create a region from rectangles that stand apart, the spaces between them are filled by thin additional rectangles to make the region continuous.
However, a block can consist of multiple regions if all the instances of a repeating group are used as a reference element. The region of a group block is calculated based on the regions of the child blocks, just like the region of hypotheses. The resulting region is slightly expanded for better viewing.

Parameters of group and repeating group blocks

A checkmark group and a common group of blocks have no parameters other than Name and Comment. The parameters of a repeating group of blocks are the same as those of non-group blocks. The Has repeating instances option is always enabled for them. Child blocks can either have the Has repeating instances option or not, but an OutputInstances variable is always created for them. If a block inside a repeating group of blocks has the Has repeating instances option, this means that it can repeat inside each instance of the parent block.

Specify a block region using instances of a repeating group

If a block is defined using several instances, the block region consists of several separate regions. If you use a particular instance of a repeating group (for example, LastFound), the block region is defined just like for any other element. However, you can use all the detected instances (AllInstances). To use multiple instances, select the Has repeating instances option. You can also write code for the block using the predefined OutputInstances variable. For example:
ABBYY FlexiCapture processes blocks with the Has repeating instances option enabled as follows:
  • For non-table blocks, the specified instances are the instances of the corresponding field.
  • For a table block, the specified instances are treated as one instance of the field. That is, ABBYY FlexiCapture processes such a block as a field of type Table with a discontinuous region.

Rules for creating references to elements for repeating groups of blocks

A repeating group of blocks refers to a repeating element. To create instances of a repeating group of blocks, you need several element instances. Therefore, one of the IDs must be AllInstances. Since the elements nested under the element with AllInstances cannot have other IDs, this condition also means that the lowermost repeating element has AllInstances. Child blocks of a repeating group of blocks refer to child elements of the repeating group of elements to which the parent block refers. The reference must have the same ID for instances. For example, if a repeating group block has the reference SearchElements..RepGr1.Instance(1).RepGr2.AllInstances, its child blocks can refer to the element RepGr1..RepGr2.Element only as follows:
If there is no HasRepeatingInstances attribute, you can only refer to subelements of the basic group that have no repeats inside it, and vice versa. If there is a HasRepeatingInstances attribute, you can refer to elements that have repeats inside the basic group (and you can only refer to all the instances at once).
With a HasRepeatingInstances attribute
Without a HasRepeatingInstances attribute
If references are created via Source element, the check is performed when the FlexiLayout is built. If references are created using Advanced code, an error is detected when matching the FlexiLayout.

Describe a block region with the FlexiLayout language

To specify the region of a block, use the Expression field. The predefined variable used depends on the type of the block and whether the Has repeating instances option is selected for it: For more information about the predefined variables that can be used in the Expression field, see Predefined variables.

Use the IsNull variable

You can also use a predefined IsNull variable to describe the region of a block. This variable signals whether the region of the block has been found when matching the FlexiLayout. The value false means the region has been found. The value true means it has not been found. The IsNull variable is initialized with the value false, so the region of the block is considered to be found. However, sometimes you might need to check certain conditions before reaching a conclusion. To tell the program to consider the region of the block found if the width of the region of the source element exceeds 50 dots, enter the following code in the Region Expression field:
To tell the program to consider the region of the block found only if Element1 has been found, enter the following code in the Region Expression field:
Suppose you need to use Element1 and Element2 to look for a block. If at least one of the elements has not been found, the block is considered not found:
This code works correctly only if the search area of Element1 is above and to the left of the search area of Element2.In the preceding example, this condition is not checked, for the sake of simplicity. In actual code, this check is required, and the values of the FieldLeft, FieldRight, FieldTop, and FieldBottom variables must be adjusted. Otherwise, calling the Rect function returns an error.