How to create document template and generate file from form a record
Template documents can be used to generate dynamic PDF or DOCX files based on each record in your table. To create a template file, follow these steps:
-
Create a Word document and design it. To use specific field data, use the
##FieldName##
parameter format. - In your application, select the corresponding view. In Design mode, select Edit View > Templates > Add. Provide a template name and choose the export format (PDF).
- Upload your template document.
- You can export a record to a PDF file from the grid or the form edit screen. In the grid, select a row and click the Actions menu to export. In the form, a button will appear at the top of the form, allowing you to download the PDF by clicking it.
Here are some other parameters and conditions that you can use within your document:
-
You can include any field's data in the document using
#FieldName#
. If you have a field for uploading image called CompanyLogo, you can include it as#Image_CompanyLogo#
. -
#Image_CompanyLogo# #{I_W175}#
: If you add#{I_W175}#
next to your image field, it will resize its width to 175 pixels. -
#InvoiceDate##{DF_dd MMMM yyyy}#
: If the field you use is a Date field, you can change its format by adding#{DF_dd MMMM yyyy}#
next to that field parameter. -
#Total##{NF_#,0.00}#
: If your field is a money field and you need to show the money in a different format, you can do it by adding#{NF_#,0.00}#
next to the field. -
#View-SubTableName#
: If you need to show each row of the sub-table in a form, you can add a table in the Word document and edit the first cell as#View-SubTableName#
. This will load all the sub-table data into this table. -
#View-SubTableName# Columns(Item; Quantity; Price#{C_#CurrencySymbol#_VALUE_NF_#,0.00}#;)
: You can further configure the sub-table columns and how to show each cell's data. For this example, it will show Item and Quantity fields as is, but it will show the price with a currency symbol and a different money format like £1,000.00 rather than 1000. -
{{if(#Number# != #empty#) My number is: #Number# }}
: You can have a condition to show a field and its label. In this example, if the Number field is not set, it will not show anything in the generated document. For instance, if the Number has a value of 10, it will show 'My number is: 10,' but if this value is not provided, it will not display the label and value.