On line guide/help
You are on page 38 of the online help. Navigate sequentially through the guide pages or search for a topic of interest to you.
Index Prev. NextConditional printing
Print an element only when a condition is true
Most of the elements accept the optional attribute printif: the element is printed only if the expression is true. If the attribute is not set, the element is always printed.
The elements that support the printif attribute are: line, box / text, rectangle / rect, circle, image, barcode, piechart, singlebarchart, barchart, linechart, gaugechart, kpichart, page.
A typical use is a template shared by different document types, or the printing of an element only when a data field has a value.
Expression syntax
The expression has the form left operator right, where left and right are placeholders or constant values. The placeholders are replaced with their values before the expression is evaluated.
Comparison operators:
= equal to
!= not equal to
> greater than
< less than
>= greater than or equal to
<= less than or equal to
If both values are numbers they are compared as numbers, otherwise they are compared as strings (case sensitive). The spaces around the values are ignored.
If the expression does not contain an operator, the element is printed when the value is not empty, not 0 and not "false". For example printif="{inv.notes}" prints the element only when the notes field has a value.
Examples of printif expressions
The < character in XML
In XML the < character is not allowed inside the attribute values and the element text: an expression like {product.stock}<10 makes the template invalid. Write < instead of the < character (so the operator <= becomes <=). The > character can be written as it is.
The expression can also be written as a child element, with the same rules.
The < character must be written as <