Powerful Document Generation

Learn to generate PDF documents

Last published at: April 18th, 2024

FlowWright now provides a very powerful document generation step that's built based on Aspose technology. You are now able to generate simple to complex documents using this new step within FlowWright; it's very easy to configure and use. 

Here are the steps in the process. 

 

Just drag the "WordDocGenerator" step from the workflow Designer toolbox and start using the step. The step has the following properties on the Settings tab. Provide the step name. Choose the report template (DOCX) from the local folder. Provide variable/global references to store the DOCX and PDF file paths (physical and virtual) as shown below. 

The step has the following properties on the Advanced tab. Provide the file name to store the PDF on the application server (the file path is stored in the variable configured above). 

The two main required properties are the "Chose report template" and "Configure data sources". The report template defines what to display within the document and the configured data sources let you bring data from different sources to generate the document. You can select an existing report template (Word document) or upload a new report template, whatever you prefer. 

 

The report template file (DOCX format) can be used;

  • to do variable replacements either in plain text or HTML
  • fill custom fields or variables in HTML
  • bind the data from the data source

The contents of a sample report template file are shown below. The variables are defined in a specific format and this can be placed along with the other document content. Like a "mail-merge" feature, the Word Document generator step shall replace the variables or custom fields either in plain text or HTML. A "for loop" Aspose syntax is used to display all the names and emails from the data source "ds.Users". For a list of all supported template functions, please refer to the Aspose documentation Template Syntax, for enumeration methods, click here.

 

Next is to configure a data source as shown below. 

 

Any number of data sources can be configured as shown 

 

Based on the above graphic, you can see 3 data sources are being defined, but only one is used on the template. Step properties also have four different step properties for providing variables for document path storage, the following paths will be stored:

Paths stored

  • generated physical document path for the Word document
  • generated physical document path for the PDF document
  • generated virtual document path for the Word document
  • generated virtual document path for the PDF document

 

After creating an instance and executing, the following Word document is generated.
 

 

The above document is generated using a simple template, more complex documents can be generated using rules, logic, and complex expressions. The expression also supports Microsoft .Net Language Integrated Query(LINQ) technology.

Once these documents are generated, the process can extended with other out-of-the-box steps to route the document to other users for review and approval, or email-generated documents to customers.