PDF Output of eForms

A PDF output of your form(s) provides form receivers with an additional option for viewing form submissions. This page explains how to configure and manage the right PDF output for your form(s).

The eForms Solution offers a Structured PDF to support you in building the right PDF output for your form(s).

What is a Structured PDF?

Much like building a form in the form builder, you can build a Structured PDF which will allow control over the content layout and data structure of your PDF output. 

A helpful metaphor for building a Structured PDF is that of building blocks. When building the PDF, you are stacking those blocks up to make a new structure.

The table below outlines the 4 types of PDF outputs offered by the eForms Solution. 

Click here for samples of each PDF output type.

As indicated in the above table - the 4 types of PDF outputs largely differ based on 2 elements:

Control over the PDF layout is available for the following PDF outputs:

  • Simplified which uses stock layout elements built and supported by the eForms team.
  • Complex which allows you to create your own layout files to control the structure of your PDF on a more granular level. As expected, there is a marked increase in complexity for the complex method. You may mix the simplified, stock eForms layout elements with complex elements built by other form owners.
  • Custom which, in addition to supporting the same layout options as that of the complex PDF output, may not follow a list-style output of form data. 

The layout structure of each option relies on the content of the template.txt file.


Note: The generic PDF output does not make use of a template.txt file. It does not require any layout configuration input.


What is a template.txt file?

Sample template.txt file


‎A template.txt file is a structured text file which the eForms Solution engine uses to determine the order in which to place .dlex files (see the 'Data segmentation' section below for more information on .dlex files). This template.txt file is also used to define any PDF error messaging. The .template.txt file uses a comma separated structure. All accepted values and expected syntax are listed below. 


The base structure of a template.txt file is as follows:
  • Use commas to separate each individual .dlex entry; begin new lines with a return key
  • You may utilise up to 3 columns, indicate columns by comma separation 
  • The first line MUST be layout .dlex file; this will be the header/footer layout for each page. By default, you may use the generic eforms layout by setting the value to 'generichybridlayout'
  • The last line MUST be questionnaireresponse. This is the final catch-all for any form data not displayed in any other .dlex segments. If all form data is captured in other .dlex segments, this area will not display on the pdf output as there will be no information remaining

Accepted values and expected syntax on a template.txt file

  • Patient pulls in the default eForms patient .dlex file which contains the standard minimum patient information, matching the requirements of 4 point matching for EMR systems
  • Practitioner pulls in default eForms practitioner .dlex file which contains the standard minimum practitioner information
  • [Customdlexexample] a placeholder, this will be the file name minus the file type for any custom .dlex files you make
  • Questionnaireresponse: [container value] displays all data found within a form.io component file. For example, if you create a well in Form.io which contains patient next of kin information, and enter that container value in, the output on of this segment on the PDF will be the next of kin information
  • Customdlexexample<I am an error message> in the event that you want to include a message for the form printer should information not be entered in on the form, you can enter a custom error message by placing it inside of a less than and greater than sign (e.g., < >). Please note that you can not enter a comma (,) in these messages. This can be used for either custom .dlex files or with eForms stock .dlex files. 
    Note: Messages entered this way will display on the printed PDF if there is no data to display in this .dlex segment.
  • <> displays a single blank space line (e.g., 1 row of white space)
  • <[Statement text to always display]> Similar to an error message, you may enter text to always display on a form by placing it inside of a less than and greater than sign (e.g., < >)

Data segmentation is only available for complex and custom PDF outputs which are made up of multiple .dlex files

What is a .dlex file?

The .dlex content files define the visual appearance and content of each part segment of the PDF output. A .dlex file is, at its core, a structured .xml file created by the DynamicPDF Designer© software. '.dlex' is the file extension used by DynamicPDF.


"The DynamicPDF Designer is a layout tool used to define templates for the LayoutEngine reports using the WYSIWYG [What You See Is What You Get] controls. Using this tool, elements are dragged, dropped, resized and moved on to a template. The template is then saved as a .dlex file, which is used in the LayoutEngine to create a PDF report." - DynamicPDF


The eForms Solution then acts as the layout engine which generates the PDF from the created .dlex files. 

For instructions on how to utilise DynamicPDF Designer©, please visit their Knowledge Base.

There are two main ways in which form content can be built into the Structured PDF: 

  • using simplified .dlex files which make use of form.io layout components to define what data to display 
  • using custom .dlex files which make use of FHIR pathways to determine which data elements to display

In addition to the above tools, the eForms Solution offers additional PDF output functionality. These include, but are not limited to:
  • Additional form logic (e.g., JavaScript conditionals and calculations)
  • Custom .dlex logic (e.g., additional calculations or display options)
  • Fully customised PDF outputs (e.g. rebuilt to match the original paper form)
Please contact the eForms team if you are interested in any of these options.

Steps to create your Structured PDF output


1Configure your .dlex and template.txt files

To use the simplified stock eForms Solution .dlex files, structure your form(s) with the PDF output display in mind. The data chunks should be displayed logically and grouped so that they are useful to the person reading the PDF.

Tip: Configure these files while you design your form(s) to ensure forms that translate well to PDF
The Form Builder has several options for container layout components:form builder container layout components pic 1.png 

  • Columns
  • Field Set
  • Panel
  • Table
  • Well


Any of these listed container components can be designated segments for display in the PDF output, and structured in the Template.txt file.


For example:

You can create a Well and place three basic components inside that well:
  • check box (e.g. 'Patient lives alone')
  • radio button (e.g. 'Patient mobility')
  • text field (e.g. 'Additional information on patient home conditions)
form builder container layout components pic 2.png

form builder container layout components pic 3.pngThis form layout can then be displayed as a segment in the Structured PDF containing data for the three basic components within the Well. To include the data for this Well in your PDF output, enter the Well’s API property name value in the template.txt file (in this example you would enter 'Questionnaireresponse: well1'). 

When building a form, think ahead to how you want the Structured PDF output to look. The same groupings that are set up in the form design will be used for display in the PDF output.

2Submit your .dlex and template.txt files to the eForms team

When you are satisfied with the design of your Structured PDF output, please:

  • Ensure all .dlex and template.txt files are entered into a .zip file
  • Ensure your template.txt file shares the same name as your form (you can confirm your form name in the Form Builder)
  • Email the files to eformssolutions@phsa.ca

3Test your Structured PDF Output

Once you have created your template.txt file and any .dlex  files, and they have been submitted to the eForms team, use the UAT environment to test the PDF output. 

Key areas to review:

  • Test both PDF draft and final submission PDF
  • Test all possible combination of .dlex  files
  • Test any/all error messaging 
  • Validate PDF  length
  • Validate header/footer content
  • Validate PDF output (consider your margin settings)

Once you are satisfied with your form’s PDF output, let the eForms team know. Form updates can be done in the future.