Premium (Add-On) Task: Office Templating

What is the Office Templating Task?

The Office Templating task is powered by PSPDFKit’s Document Engine which allows for PDF and Docx files to be created from request data using a Docx file template that contains ‘placeholders’.

Why the Office Templating Task (Office Templating VS. PDF Generator)?

  • Easier template creation. You can now design your document template with any editor that can save a docx file, as opposed to the cumbersome fillable PDF creation that requires a third-party tool..

  • Grid mapping. Office Templating enables you to map complete grid data into your document, which isn’t currently supported by the traditional PDF Generator task.

  • Flexibility in mapping multi-option questions. Office Templating offers various representations for those question types.

  • More Document Types supported. You can now choose to output your document either as PDF or Docx file.

How do I generate a PDF/Docx document from a Docx template?

1. Design a Docx template with placeholders using MS Word. Below is a Docx template example:

A placeholder is a unique identifier surrounded by delimiters in your template file that defines a location that you would like data to be inserted. These placeholders can be mapped to any text data source in a request. Placeholders must be alphanumeric, without spaces, and unique. The default delimiters are {{ and }}, but you can define any delimiters you wish to use.

There are two types of placeholders that you can have in your template document.

  • Single placeholders

  • Loop placeholder sets

Single placeholders look like {{invoice_number}} , and are used for one-to-one mapping of text-based data into your document.

Loop placeholder sets consist of an opening placeholder, a closing placeholder, and any number of placeholders in between. The opening placeholder starts with a ‘#’, while the closing placeholder is the same but starts with a ‘/’. The placeholders within the loop only need to be unique within that loop. Loop placeholders are useful for mapping grid questions and multi-option questions like radio buttons and checkboxes. They allow you to loop through rows in grids and options in multi-option questions. For example, the “Loc_array” is an array placeholder that includes two single placeholders: “add_label” and “add_value.”

{{#Loc_array}} {{add_label}} {{add_value}} {{/Loc_array}}

2. Add the Office Templating Task to your process.

Select Configuration > Configure Task:

The following is required on the General Settings tab:

  • In DOCX document template, upload your Docx file template.

  • In Output Format, choose PDF or DOCX as your output.

  • Specify your Start Delimiter and End Delimiter defined in your template.

  • Select your Prefills to add dynamic values to the Name of completed file. You can add as many prefills as you want. The .docx or .pdf extension will be added automatically based on the output format selected.

  • Click “Save”.

Next, Select the**“MAPPINGS”** tab.

You will see that all the placeholders wrapped by {{}} in your template have been automatically detected by the system. Now you need to complete the mapping for each placeholder.

How to Map text-based questions (Short Text, Calendar, Search Box, etc.)

Simply map the single placeholders, for example {{invoice_number}} to a desired data source.

Example of a text-based question mapping:

How to Map multi-option questions (Checkbox, Radio Button, Select List)

  • Checkbox:

First, map the loop placeholder you defined in the template to a checkbox question in the form, for instance, “Loc_array”.
{{#Loc_array}} {{add_label}} {{add_value}} {{/Loc_array}}

You can choose to display All options or Only Selected options in the output. Hit “Save”.

Then click the icon below to expand/collapse additional settings.

Choose Label for “add_label”, and Selected Status for “add_value”. Select the type of representation you want within the Represented As field. Then click “Save”.

Below is an example of a checkbox mapping in a Checkmark/Cross representation; All Options VS Only Selected Option:

  • Radio Button

Radio button is not much different from a Checkbox in terms of mapping, except that it only allows a single option.

Example of a radio button mapping:

  • Select List

If you simply want to display the selected value as is in your output, use a single placeholder and map it like any other text-based questions.

If you want to display the select list in a graphical representation, define a loop placeholder and map it in the same way as a radio button or a checkbox.

Below is an example of a select list mapping (only label is mapped):

How to Map a Grid:

Create a loop placeholder in your Docx file named items , with all the elements in between. Each element corresponds to a column in your grid.

Qty. Item# Description Unit price Line total
{{#items}}{{quantity}} {{number}} {{description}} {{price}} {{total}} {{/items}}

Map “items ” to the grid question on your form. Click “Save ”.

Then map each element to a column in your grid. Specify a format if it is a Currency type.

Add a parameter for Total. Select the Grid question on the form for the Field. For ‘Which Options’ choose Specific Cel l, for ‘Row’ choose Footer , and for ‘Column’ chooseLine Total.

Example of a grid mapping:

Contact your customer success team to learn more about adding this premium feature to your license!

Click here to email us!