Creating Document Definitions

A Document Definition describes the location of document elements and indicates the fields to be used in data extraction.

Document Definitions can be obtained in one of the following ways:

  • A Document Definition may be part of an ABBYY FlexiCapture 12 project. When creating a Document Definition in ABBYY FlexiCapture, field properties are specified along with their range of values. Data export settings are also configured.
  • A Document Definition may be created in the project by calling the AddNew method of the DocumentDefinitions object.
  • A Document Definition may be loaded from a file to the project with the help of the LoadFromFile method of the DocumentDefinitions object.

Below are detailed instructions for creating Document Definitions using ABBYY FlexiCapture SDK.

A Document Definition can comprise any number of sections. The section of a Document Definition is a set of pages (or a single page) and fields on these pages which corresponds to a logically complete part of a document. Using ABBYY FlexiCapture SDK, you can create a simple Document Definition, which consists of a single section, or a compound Document Definition with several sections.

Creating a compound Document Definition

  1. Open the project and get the collection of Document Definitions of the project.
  2. Create an empty Document Definition using the AddNew method of the DocumentDefinitions object.
  3. Switch the Document Definition to editing mode by calling the CheckOut method of the DocumentDefinitions object.
  4. Set the language to be used with this Document Definition during recognition. Use the DefaultLanguage property of the created DocumentDefinition object.
  5. Set the default text type using the DefaultTextType property of the DocumentDefinition object.
  6. Create a new fixed section from an XFD file:
    1. Add the new section into the Document Definition with the help of the AddNew method of the SectionDefinitions object.
    2. Load the XML Form Definition into this new section using the LoadXFDDescription method of the new SectionDefinition object.
  7. Create a new flexible section from an AFL file:
    1. Add the new section into the Document Definition with the help of the AddNew method of the SectionDefinitions object.
    2. Load ABBYY Flexible Layout into this new section using the LoadFlexibleDescription method of the new SectionDefinition object. You can also load it from stream using LoadFlexibleDescriptionFromStream method.
  8. Create a new section with necessary fields from scratch.
    1. Add the new section into the Document Definition with the help of the AddNew method of the SectionDefinitions object.
    2. Get the collection of fields of the section using the Fields property of the SectionDefinition object.
    3. Add new field definitions by calling AddNew method of the FieldDefinitions object.
  9. Repeat the steps 6-8 if necessary.

Setting additional properties

To improve the quality of recognition, you may configure the types of field values:

  1. For a section of the created Document Definition, get a set of its field definitions. Use the Fields property of the SectionDefinition object.
  2. Find the necessary field definition. Note that fields may be simple (without an internal structure), or composite (such as a table field where each cell can be viewed as a separate subordinate field of the table). Therefore, to iterate through all field definitions of the section definition, it is not enough to iterate through all the elements of the ISectionDefinition::Fields collection, you should also check if the field is composite and access its child fields (see the IFieldDefinition::Children property).
  3. Set the type of the field value using the ValueType property of the FieldDefinition object.

Sometimes it is not convenient to specify any particular type of field value as this restricts field values. E.g. if a user enters incorrect data into such a field, this will produce an error. To avoid specifying some special type of field value, you may create a special language for the field and set its parameters for recognition of a specific text. For details see Setting up Recognition Languages.

You may also set other recognition parameters using the IFieldDefinition::RecognitionParams property.

Checking Document Definitions

Check the created Document Definition. Use the Check methods of the DocumentDefinition object and SectionDefinition subobjects. These methods check a Document Definition for errors. If there are errors, the lists of errors are available in the Errors properties of the DocumentDefinition object and SectionDefinition subobjects.

Saving Document Definitions

If there are no errors after checking the Document Definition, call the CheckIn method of the DocumentDefinitions object to save the Document Definition with all the properties you have set. Or you can use the UndoCheckout method of the DocumentDefinitions object to discard all the changes that you made.

See also

DocumentDefinition

15.08.2023 13:19:30

Usage of Cookies. In order to optimize the website functionality and improve your online experience ABBYY uses cookies. You agree to the usage of cookies when you continue using this site. Further details can be found in our Privacy Notice.