Document Generation

The document generation step generates Word documents that report extracted data.

Generated documents are based on templates that uses a jinja script. Template files are Word Documents (.docx) that rely on a specific directory structure:

  • The template files must reside in the _resources folder.

  • The _resources folder must reside at the same directory level as the .ibflow file.

You can generate documents only after an apply refiner step, because document generation configuration depends on field names specified in Refiner.

Mapping configuration file

A configuration file, field_mapper.json, maps refined fields to tags in each template file. You can define one or more template file names, each with a mapping object that includes refined field value pairs.

Here’s a sample mapping configuration:

[
  {
    "template_filename": "FirstTemplate.docx",
    "mapping": {
      "Vendor_Name_in_template": "refiner_phrase_label",
      "First_Item": "first_item",
      "Second_Item": "second_item",
      "Recipient_Name": "receiver",
      "Total_Amount": "total_amount",
      "Generated_using": "Document generation"
    }
  },
  {
    "template_filename": "SecondTemplate.docx",
    "mapping": {
      "First_Item": "first_item",
      "Second_Item": "second_item",
      "Total_Amount": "total_amount"
    }
  }
]