Creating a Fixed Layout Document Definition using SDK

  • Last Post 14 March 2014
  • Topic Is Solved
sreejith posted this 10 March 2014

Is it possible to create Fixed Layout document definitions (.fcdot) files using only FlexiCapture SDK? I do not want to use an AFL or and XFD.

My system would work as follows

  1. My application will be listening to a messaging queue where requests for either processing images or creating new templates will come
  2. The data for creating the template will arrive as a JSON which my application will parse and use the objects created through FC Engine SDK to create a Document Definition and save it as a .fcdot file
  3. List item

The important points are

  1. All my document definitions are fixed layout. So I do not want to use AFL
  2. I do not have multiple images to train the system. I get a single page with the position and other details of the fields in it. I want to create the document definition

I tried the following approaches

Using AFL

This follows the method given in the documentation and the sample code from Auto-learning Demo. I used the following steps

  1. Created an ITrainingBatch and added the page image using AddPageFile function.
  2. Based on the type and location given for each field from the parsed data from JSON, added blocks using Blocks.AddNew function. The region is created based on the details from my JSON request.
  3. Saved the definition to AFL and FCDOT formats according to the sample code

Problems faced

  1. When the saved definition was loaded to a processor, and tried for recognition, the recognition was very wrong.

  2. The location of the recognised areas were all wrong. Often the entire image is recognised as a single field

Using IDocumentDefinition

  1. I created an IDocumentDefinition object using CreateDocumentDefinition function of an engine.
  2. Added a new section to this using Sections.AddNew. The name of the section was the name of the page.
  3. Added a new page to the section using Section.Pages.AddNew.
  4. Added blocks to the Page using Page.Blocks.AddNew.
  5. Checked the document definition using Check. I got the following error “Document Definition, Page 1: Page has no elements for Document Definition matching”

Using a mix of the two

In this, I created Anchor blocks using the data from ITrainingBatch and added it to the DocumentDefinition.

  1. Created a IDocumentDefinition, ITrainingBatch and ITrainingDocumentDefinition
  2. Added Sections and Pages to both objects
  3. Did a Page.PrepareLayout to do initial recognitions
  4. For each ImageObject in the page, got the Region and added a new block to the DocumentDefinition as Anchor block. There were more than 2000 of these
  5. Checked the document definition using Check. I got the following error “Document Definition, Page 1: Block 'Anchor 115' is too small.”

However, I saved the definition and tried processing with it. When loading the definition, all the blocks were correctly present in the template On processing, I got the following error

“No Document Definitions to match.”

Creating Fixed Layout from Flexible Layout I tried creating a Flexible Layout according to the documentation and added a dummy field and a dummy reference field. Then I saved this as AFL Then I loaded it as IDocumentDefinition using ICustomStorage::LoadFormFile. I tried to use this as a base for adding fixed layout fields. However I got the following error

"Additional information: Unable to define fixed layout inside flexible."

Order By: Standard | Newest | Votes
SDK_support posted this 12 March 2014

We have received your letter with this description sent to and have already answered on it via e-mail.

sreejith posted this 12 March 2014

The solution suggested in the mail was to set DefaultLanguage and DefaultTextType. However setting this did not change anything. I am still seeing the same errors.
Also updating the question with another thing which I tried

SDK_support posted this 14 March 2014

We are keeping on investigating this case in correspondence via e-mail.

microsign posted this 14 March 2014

I don't want to be rude, but isn't the whole idea of an open forum such as this one to keep everyone informed of the progress of a solution and closing a question with a final solution?

Why keep this all in private emails that are invisible for others that are looking for an answer to a similar problem?

SDK_support posted this 14 March 2014

The message “No Document Definitions to match” can appear in case the used document definition cannot be applied for the processed image.

At least one Anchor (static element) on the page is required. It can be a reference mark - an element of a machine–readable form that is used to facilitate the matching of form images with templates and to determine the orientation of forms during automated processing or some static text, separators, barcodes. Before the program can start recognizing the contents of the form, it must match the form with its template.

Also according to the code snipped you have sent to us and .fcdot file, we could suggest that some errors can be caused by matching first element - static text (“PAYBACK”) as BlockType = BT_Anchor. This type is usually uses for some special elements of form design such as a black square, rectangle, cross or corner. Please try to set BlockType to the text “PAYBACK” as BT_StaticText.

  • Liked by
  • sreejith
sreejith posted this 14 March 2014

microsign. That was partly my fault. I had mailed Abbyy support before posting here. Then it was recommended from their Facebook page that I post here. So they mailed me some suggestions and updated here. The thing which finally worked is below. I will create a Wiki page with a detailed guide when I have solved the whole thing