Hide a line if an element is empty

When creating a template, some value may be optional and it creates an empty line the generated document.
It is possible to remove a line based on condition, here is an example using the following JSON dataset:
{
"firstname": "John",
"lastname": "Wick",
"address1": "221B Baker Street",
"address2": "",
"city": "London"
}

An ODT template is create and it is printing all of the information above, except the address2 if empty, such as:

ODT Template with a condition wrapping the line {d.address2}

In order to hide the line, the expression {d.address2:ifEM:hideBegin} is placed just before the value and the {d.address2:hideEnd} just after the break-line.
Here is the result:

Generated PDF document

To hide the address1 and city if values are empty, it is possible to add expression, such as:

ODT Template - Optional lines: address1 address2 city

When using conditional blocks, we recommend to use only break-lines shift + enter, learn more on the following article
Was this article helpful?
Cancel
Thank you!