Generate Disclosure Form from Template

A web form submission can be reproduced as a PDF to serve as a record of the answers given online.

The template shows how to display check boxes, radio buttons and multiple tick boxes. 

Conditional logic can be used to exclude a non-applicable section of the form, whilst repeating logic allows multiple responses to a question. 

This example in detail

Adding a form timestamp

It is possible to display the precise time that a form is filled out.

The time can be derived using the built-in variable $nowUTC.

$nowUTC returns the current date/time in UTC. (coordinated universal time)

The timeOffset field in the data,  provides the difference in hours between the relevant time zone and UTC.Data field to change time zone of current date in generated document

By using the dateAdd function, in combination with $nowUTC and the supplied timeOffset it is possible to shift the date/time to the required time zone.

Template snippet to add current date and time in a specific time zone.

In this example, the timeOffset of "-4" is applied to the UTC date/time to localize it for Boston in the United States.

The result is the date and time appearing in the following output format on the form.

Generated document snippet to add current date and time in a specific time zone.

Using tables to control the layout

Tables are used to control the layout and positioning of information on the form.

 Template snippet using Tables for formatting

 

Tip: To see the individual tables that are used in the different sections of the form, choose View Gridlines on the Layout ribbon.

Merge Cells and Split Cells are used to achieve the desired layout for each table. 

Fixing the size of tables

To ensure the tables in the different sections of the form don’t expand in an unpredictable way when filled with data, the layouts are kept “fixed” in size.

To achieve this:

  • Ensure the Automatically resize to fit contents check box is unchecked.

    Changing properties of table in template to generate consistent documents

  • The exact height of each table row is specified.

    Specify table cell height in template

Using shading for answer boxes

This example shows that table cell shading can be used to highlight the answers.

Using word features to generate stylized documents

Using wingding symbols

In Microsoft Word, there are webdings and wingdings that display as graphical symbols.

Some of these symbols such as check boxes, ticks and crosses are useful for replicating form responses. 

The wingding fonts below have been used to create this form example.

wingding fonts to create checkboxes in generated documents

These wingdings can be accessed from the Insert ribbon.

Inserting wingding symbols in the template

Using check boxes

Check box questions provide a choice between one of two mutually-exclusive options. 

Snippet of generated document displaying checkboxes

A user will answer either:

  • Yes with the Yes box checked and the No box kept unchecked.

    OR

  • No with the Yes box left unchecked and the No box checked.

 

With a check box question:

  • A boolean field from the data determines whether Yes (true) or No (false) has been selected.
    Data snippet to replace fields in the document generation template

  • An Else-if statement determines whether the Yes box should be checked or unchecked.
  • Another Else-if statement determines whether the No Box should be checked or unchecked.

Note:  Checkbox questions require two Else-If statements to address both possible options.

Snippet of template displaying code for the check boxes

Using radio buttons

Radio buttons allow only one option to be chosen from multiple answer options.

In this example, the chosen option is represented as a wingdings dot within a table cell. 

Snippet of the generated document displaying radio buttons

A single text field in the data stores the chosen option.

Data for Radio button in template

In the table cell next to each option, is a semi-hidden <<cs_ If statement that checks whether the user has chosen this option and if this is true, a dot is displayed.

Snippet of template displaying code for the radio buttons

Using multiple tick options

Multiple options can be selected for the question below.

Snippet of the generated document displaying multiple selections

The data shows a boolean field for each option.

Data for multiple selection in template

In the table cell next to each option, is a semi-hidden <<cs_ If statement that displays a wingding tick if the boolean value is true.

Snippet of template displaying code for the multiple selection

Creating conditional questions

It is possible to exclude certain questions from showing, based on the answers to previous questions.

Here if  the answer to the question “How often do other people drive the vehicle?” is Never, then the  subsequent question “Can you please name the other drivers?” is not applicable.

Here the <<cs_{anyOtherDrivers!=’Never’}>> conditional expression ensures that this second question only shows if the answer to the prior question is not Never.

Snippet of template displaying conditional logic in the template

 

For further information on conditional expressions, refer to Conditional Sections.

Allowing multiple responses to a question

Some questions can have one or more answers.

Snippet of generated document with repeating section

In this example, the otherDrivers array shows the answers given to the question.

Array data to populate a repeating section in the template

Here, the <<rr_ statement loops over the answers in the otherDrivers array, adding a new table row for each answer.

Snippet of template with repeating section placeholders

For further information on using <<rr_  statements refer to Tables – Part One.

  

Feedback

Invalid Input

Sorry, this field will only accept letters and numbers, and not special characters, to limit spam. Please also consider contacting support@docmosis.com if you need help with this article.

Sorry, this field will only accept letters and numbers, and not special characters, to limit spam.

Invalid Input

Document Gallery

Docmosis showcases its template-based document generation capabilities through a gallery of downloadable PDF documents. The gallery features a mixture of real documents provided by customers as well as links to PDFs generated from example templates, desgined to illustrate the versatility of Docmosis.