To generate custom documents from response data, you must first prepare a template for OpenForms to pipe that data into. These templates can be in Microsoft Word or Adobe PDF format.
This article describes when to use Microsoft Word templates, and how to prepare them for upload to OpenForms.
For information on preparing Adobe PDF templates, see Format Adobe PDF templates for custom documents.
About Word templates
When response data is piped into Word templates, other content is shuffled down to make room.
This makes Word templates a perfect match for forms that might invite lengthy responses, such as grant applications or surveys containing open-ended questions.
Word templates are also easier to prepare than PDF templates, so you might use them for any custom document that doesn’t require rigid styling. Standardized letters, simple receipts and permits are all good use cases for Word templates.
Once uploaded to OpenForms, you can configure Word templates to generate as PDF custom documents, so you don't need to worry about respondents or staff being able to edit data.
When not to use Word templates
Word templates are generally less suited than their PDF counterparts for generating custom documents that feature extensive styling or need to rigidly match an exact layout.
Because of the way OpenForms data is piped into Word templates, you may find a template's carefully arranged layout shifted to accomodate wordy submissions when you start generating documents from it.
Microsoft Word also offers fewer design and layout options than Adobe Acrobat, and some form data, such as checkbox and radio button selections, is piped into Word templates as text rather than visual indicators.
If you have a specific design goal in mind for a custom document, it's best to generate it from a PDF template.
Prepare a template
-
Use Microsoft Word to create the template for your custom document. Prepare your template exactly as you would a normal document. There's no need to use any of Word's templating features.
Aside from the data that will be piped in from OpenForms, your template should be complete, including any graphical or layout elements you’d like to use.
-
Wherever you’d like to pipe in OpenForms data, create a template field using curly brackets “{{}}” and a descriptive name that matches the OpenForms field you’d like to pipe data in from.
For Word templates, this name does not have to be an exact match to your form's fields. You can't use spaces and special characters in the template field. But it can consist of letters, numbers, hyphens and underscores.
See What data can be piped into custom documents for a full list of the data you can pipe into Word templates.
-
If your form contains repeatable groups and you'd like to pipe data from those groups into your template, make sure you include fields for the maximum number of repetitions for those fields, as defined in your groups' field settings.
In the example above - for an expense reimbursement form - a respondent can enter up to four itemized expenses.
To create a Word template that includes these expenses, create template fields for every one of the the maximum number of possible answers (even if some respondents may only enter a single expense). In the generated document, any repetitions respondents does not use will be left blank.
- If your template includes a signature field, make sure the line spacing of that fields is not set to an exact value, as this can truncate a piped signature image.
To do this, select the signature field in your Word template and choose Line spacing options... from the line spacing dropdown.
Select any value other than "Exactly".
-
Do not leave large spaces or insert lined areas for text, as below.
When your custom documents are generated, these areas will simply be shuffled down, leaving an ugly gap in your document.
Instead, simply add a template field to tell OpenForms you’d like to insert text in that space.
Your form data will be piped in and take as much space as it needs.
-
Once you’ve completed your template, save it in .doc or .docx format.
Supported formats
OpenForms supports Word templates saved as .doc and .docx files using the following file versions:
-
Microsoft Word 2003, 2007, 2010, 2013, 2016
-
OOXML (Office Open XML)
-
Flat OPC
Uploading a template saved using a .doc or .docx version not listed here may cause errors when mapping your template or generating custom documents.
Embed custom fonts
To ensure the custom documents generated from your template render correctly, it’s a good idea to embed any paid or custom fonts you’ve used in your template when you save the file.
Here’s how to embed fonts using Microsoft Word.
Some font licenses do not allow embedding into Word or PDF documents. If you’re embedding custom fonts into a template, we recommend checking how the template renders on a device without those fonts installed after you’ve created it. Font licensing is a complex area. If your organization uses paid or custom fonts, your design team or brand manager should be able to tell you more about how to proceed.
Embedding custom fonts can significantly increase the size of Word templates and the custom documents generated from them. If you generate a lot of custom documents from a template containing embedded fonts, this can impact your storage quota.
Sample templates to get you started
We've prepared a couple of simple Word templates to get you started creating custom documents.
Download the files below to see how easy it is to prepare a tax receipt or permit template for upload to OpenForms.
Feel free to replace our sample text and images in either of these files with your own organization's details and use them to generate your own custom documents.
What next?