Special features of ABBYY FlexiLayout Studio for creating additional FlexiLayouts
ABBYY FlexiLayout Studio has several special features for developing additional FlexiLayouts for invoice projects:
- You can specify the locations of elements relative to the regions of fields that were detected when the main FlexiLayout from the invoice project was applied.
- Identifiers of vendors and business units can be used in requests to the data set of the Document Definition.
- Lists of keywords and other parameters of a FlexiLayout can be exported to an XML file, allowing you to edit them without editing the FlexiLayout or the Document Definition.
How to create an additional FlexiLayout
- Open a batch with recognized invoices in ABBYY FlexiCapture.
- Create a new project in ABBYY FlexiLayout Studio. On the main menu, select Tools → Export Batch to FlexiLayout Studio → Create New FlexiLayout Studio Project....
Note: This command is only available for ABBYY FlexiCapture projects that are stored on your computer. If you are using the Distributed version of ABBYY FlexiCapture and the project is stored on the server, you will first have to download it to your computer by clicking Export Project... on the Project menu.
Note: The suffix of the ABBYY FlexiLayout studio project indicates the version of the Document Definition at the time of the project's creation.
The ABBYY FlexiLayout Studio project you just created contains all of the documents from the ABBYY FlexiCapture batch, and the regions of fields detected during recognition in ABBYY FlexiCapture in the form of a reference layout.
Tree | Node | Description |
SearchElements | CommonBlockRegions | This node contains elements that correspond to all fields of the Document Definition. The coordinates of all regions of blocks that were detected when FlexiLayouts were applied to each document in ABBYY FlexiCapture are saved in the ABBYY FlexiLayout Studio project. By default, regions with these coordinates will be assigned to elements that have the same name as fields in the Document Definition. This allows them to be used to specify relative locations of elements and for creating new elements. |
CustomSearchElements |
This node contains sample elements. They are disabled by default in order to avoid interference when the FlexiLayout is applied. DataSetRequestSample - An example of a request to the data set of vendors and business units that are stored in the Document Definition. This data set includes identifiers of vendors and business units. |
How to add a field to an additional FlexiLayout
To add a field to an additional FlexiLayout, you will have to create a block for this field and specify its search element.
Fields in the Document Definition have to have unique names. This means that:
- To describe the search logic for a field, you have to create a block with a unique name.
- To change the search logic for a field that already exists in the Document Definition, you have to create a block with the same name.
How to add pages to an additional FlexiLayout
If you want to test the changes you have made to an additional FlexiLayout on new images, you can export your ABBYY FlexiCapture batches into an existing invoice project in ABBYY FlexiLayout Studio. To export your batches, click Tools → Export Batch to FlexiLayout Studio → Add to Existing FlexiLayout Studio Project....
- You can export ABBYY FlexiCapture batches only into those ABBYY FlexiLayout Studio projects which were created by selecting Tools → Export Batch to FlexiLayout Studio → Create New FlexiLayout Studio Project....
- When you export a ABBYY FlexiCapture batch to ABBYY FlexiLayout Studio, a new batch will be created in ABBYY FlexiLayout Studio for that batch.
- If the New Document Definition has more fields than the Document Definition used for the ABBYY FlexiLayout Studio project, the export log will contain a warning for each extra field.
- To make the program export the extra fields, for each extra field add a block with the same name in the CommonBlockRegions node of the SearchElements tree.
How to make requests to data sets from the Document Definition
You can find a sample request in the DataSetRequestSample element. This element is disabled by default.
Type | Description |
NamedValue | A named value |
Constructor | |
NamedValue( String, String ) | |
Methods | |
String Name() | Returns the name of a named value |
String Value() | Returns the value of a named value |
NamedValueArray | An array of named values |
Constructors | |
NamedValueArray() | |
NamedValueArray( NamedValue namedValue ) | |
Methods | |
Int Count() | Returns the total number of elements in the array. |
NamedValue GetAt( Int index ) | Returns the element with the specified index number. |
Void Add( NamedValue namedValue ) | Adds a named value to the array. |
Void Add( NamedValueArray namedValueArray ) | Adds a named value array to a named value array. |
Void InsertAt( Int index, NamedValue namedValue ) | Inserts the namedValue into the position index. |
Void DeleteAll() | Deletes all elements in an array. |
Void DeleteAt( Int index ) | Deletes an element in the position index. |
Int FindByName( String name ) | Returns the position of the value named name. |
Functions
Syntax:
- The path to the Document Definition and the name of the data set will be used to access the data set when working with a FlexiLayout in ABBYY FlexiLayout studio.
- After a compiled FlexiLayout is added to a Document Definition in ABBYY FlexiCapture, only its name will be used when accessing the data set.
- connectionString format:
"dbtype=FCDataset;fcTemplate=path_to_Document_Definition;datasetName=name_of_Data_Set;"
Note: Parts of the path need to be separated by double backslashes "\\"
- searchFields
Array of names of columns from which values need to be retrieved. - searchCriteria
Array of Column-Entry pairs, returns all values if empty. - If a request contains multiple values for one field, use the OR Operator
- If a request contains multiple values each of which corresponds to only one field, use the AND Operator
- If a request contains multiple values for one field and values for multiple fields, use the OR Operator to distinct multiple values for one field and the AND Operator to conjunct values for various fields.
Definition | Description |
Logic TestAccessToFCDataSet( String connectionString ) | Tests connection to the data set |
Logic TestFCDataSetSearchCriteria( String connectionString, StringArray searchFields, NamedValueArray searchCriteria ) | Tests search conditions for data set |
StringArray FieldNamesOfFCDataset( String connectionString ) | Returns a list of all fields from the data set sorted in ascending order of their index numbers. |
StringArray FieldNamesOfFCDataset( String connectionString, StringArray searchFields ) | Returns a list of data set fields from the specified data set in ascending order of their index numbers. Should be used in conjunction with the RecordOfFCDataset function when there are complex columns. |
Int RecordCountOfFCDataset( String connectionString, StringArray searchFields, NamedValueArray searchCriteria ) | Returns the amount of entries from the data set that is specified in the search conditions. Used for finding out how many entries may be returned using the RecordOfFCDataset function. |
Void PrepareRecordsetOfFCDataset( String connectionString, StringArray searchFields, NamedValueArray searchCriteria, Int maxRecordsCount = DefaultMaxRecordsCount ) | Prepares data for a query to the data set. This needs to be performed for every new set of search conditions before calling the RecordOfFCDataset function. |
StringArray RecordOfFCDataset( String connectionString, StringArray searchFields, NamedValueArray searchCriteria, Int rowIndex ) | Returns an array of values from the entry with the number rowIndex from results returned by a query to the data set. The number of values is equal to the number of fields passed in searchFields (this includes the case of complex columns). |
Quality ValidateByFCDataSet( String word, String connectionString, Int fieldIndex, NamedValueArray searchCriteria, Int maxErrors, Rational maxErrorsPart, Logic ignoreSpaces = true, Int maxRecordsCount = DefaultMaxRecordsCount ); | Returns the quality of the string word. Accepts index numbers of fields. You can get index numbers by indexing the output of the FieldNamesOfFCDataset function. |
Void SearchTextFromFCDataSet( String connectionString, Int fieldIndex, NamedValueArray searchCriteria, Int maxRecordsCount = DefaultMaxRecordsCount ) | This function is used to specify search conditions for words for the Static Text function. When this function is called, existing search conditions are replaced with new ones. Accepts field index numbers. You can get index numbers by indexing the output of the FieldNamesOfFCDataset function. |
Void RegularExpressionFromFCDataSet( String connectionString, Int fieldIndex, NamedValueArray searchCriteria, Int maxRecordsCount = DefaultMaxRecordsCount ) | This function is used to specify search conditions using regular expressions for the CharString function. When this function is called, existing search conditions are replaced with new ones. Accepts field index numbers. You can get index numbers by indexing the output of the FieldNamesOfFCDataset function. |
How to search for rows from a column from an external database on an image
- Use FieldNamesOfFCDataset to get a list of columns sorted in ascending order of their index numbers.
- Determine the index number of the column from which you need to find data.
- Create an array of conditions for filtering data from the data set.
- Pass the index numbers of the column and the filter conditions to SearchTextFromFCDataSet (or RegularExpressionFromFCDataSet, if you need to use regular expressions).
This code will be automatically generated when a recognized batch is exported from ABBYY FlexiCapture
How to search an image for entries from multiple columns of an external database
Since search parameters are replaced each time you call the SearchTextFromFCDataSet function, calling this function several times over is pointless. There is a workaround for this: you can get strings from an external database and pass them in the SearchText function. Calling this function adds the string to existing search parameters instead of replacing them.
To do this, complete the following steps:
- Create an array of names of columns from which you need to find data.
- Create an array of filter conditions for filtering data from the data set.
- Determine the amount of entries that will be returned using the RecordCountOfFCDataset function.
- Prepare query data using the PrepareRecordsetOfFCDataset function.
- Go through all records and get the array for each record using the RecordOfFCDataset method.
- Pass the value of each element in the array to the SearchText function.
Additional considerations when dealing with complex columns
- The FieldNamesOfFCDataset function returns an array that will contain multiple occurrences of the name of the complex column. The number of occurrences will be the same as the number of column instances in an encoded external database.
Example: {VendorId, VATID, Name, Name, Name, City}. In this case the external database contains 3 columns for the one complex column Name in data set. - If SearchCriteria contains a condition for a field that corresponds to complex column (like in the example above), this condition will be used to check all of these column instances.
- If searchFields contains a condition for a field that corresponds to complex column (like in the example above), the result will contain the array of values from each column instance.
For example, if for {VendorId, VATID, Name, Name, Name, City} you request
searchFields = { VATID, Name, City}, you will receive
{VATID_value, Name_valueInColumn1, Name_valueInColumn2, Name_valueInColumn3, City_value}
- You can get a list of columns that will be returned by passing the searchFields array to the FieldNamesOfFCDataset function.
How to make a request to an XML file that contains FlexiLayout settings
You can make requests to an XML file with FlexiLayout settings using two standard functions that are described in documentation for ABBYY FlexiLayout studio:
StringArray ReadFromXML(String filename, String xPathQuery)
String ReadSingleStringFromXML(String filename, String xPathQuery)
This file has to be located in the ABBYY FlexiLayout Studio project folder subfolders if you want to use it when working on a FlexiLayout in ABBYY FlexiLayout studio. The path to this file is relative to the ABBYY FlexiLayout Studio project file.
If you load a compiled FlexiLayout to a Document Definition in ABBYY FlexiCapture and use it as an additional FlexiLayout, the XML file will be placed in the Templates folder and you will be able to edit it. When the FlexiLayout is applied, the program will manage access to this file automatically.
12.04.2024 18:16:02