Formatting within pdfMachine merge

pdfMachine merge supports full liquid templating language in HTML templates and the email body, and also has partial support for liquid (liquid filters only) in Microsoft Word/Excel/PowerPoint document templates.

Liquid allows you to apply formatting, perform loops, conditionals etc based on the values from your datasource. All the standard filters and tags are supported as mentioned here Liquid For Designers and here DotLiquid For Designers.

Note: To use Liquid Templating Tags in the email body the email body editor should always be in "Source" mode. The "wysiwig" mode will not preserve the Liquid Tags.

Using filters to format merge fields

Liquid contains filters which process the value of merge fields before output.
eg. {{ name | capitalize }} which capitalize words in the input sentence.
pdfMachine merge also has some custom filters (not part of Liquid specification) for dates, numbers and currency.

Examples of merge field formatting can be found here.

Specific examples :

Looping and conditionals

Liquid also contains tags which support looping and conditionals
eg.
{% for desc in desc_array) %} html here {% endfor -%} which repeats the enclosed html for each of the elements of desc_array.  Note: Use forloop.index0 for the current index.
{% cycle 'rows':'LightGreyBackground', 'DarkGreyBackground' %} to alternate row colors in a table.

For an example of using the above in a template:
Click here to see an example HTML merge template using liquid.
Click here to see an example of the PDF generated.
When you install pdfMachine merge, a profile is setup with this demo invoice template, which you try out and customize to your requirements.

When using HTML templates, for best results you will need to set certain print options in Internet Explorer

  • Turn off Internet Explorer print headers and footers by File | Page Setup and change them all to "empty"
  • Turn on background colors for printing by File | Page Setup, tick "Print Background Colors and Images"

If you need help or more information on this feature please contact

Line items /Bundled data

Rows from the data source can become line items in the email or PDF.

Bundled data can be formatted using javascript or as liquid arrays.
If there is a column in the data source called description, it is available as {{description}}
Where there is bundled rows (multiple rows with the same email address) in the data source, the multiple rows are passed in as an array in a variable called description_array.  This is accessed as {{ description_array[0] }}, {{description_array[1] }} etc.

Review the example profile here to see how to set up a profile with line items.