Functions
Number functions Format number Format a number with grouped thousands and optionally decimal digits. {% number_format([float number], [decimal_places], [decimal_separator], [thousands_separator]) %} Round Round the float number based on the precision from the second parameter. {% round([float number], [integer precision]) %} Ceil Rounds to the nearest integer up. E.g. 2.1 => 3. {% ceil ([float number]) %} Floor Rounds to the nearest intFeaturedCommon use-cases of the Expression language
Using Filter and Iterate function Let's say you have an array of line items, where items can be of different type (e.g. "Food", "Drinks", etc...) and you need to get a SUM of a specific type. Then you can do it using a combination of filter and iterate function: {% sum(iterate(filter({line_items}, 'type == "Drinks"'),'total_price')) %} Example JSON dataset: [ { "line_items": [ { "name": "Cola", "price": 2, "qty": 2, "total_price": 4,PopularDate functions
Date Format date value. {% date({dateString}, {timezone}, {addDays}, {outputFormat}, {inputFormat}) %} Examples of the function "Date": Display current time {% date('now') %} Specify timezone {% date({dateValue}, 'UTC') %} Specify output format {% date({dateValue}, 'UTC', 0, 'd/m/Y') %} Specify output and input format {% date({dateValue}, 'UTC', 0, 'd/m/Y', 'm/d/Y') %} Datetime Format datetime value. {% datetime({datetimeString}PopularHow to access a specific array element?
It is possible to use expression language to access specific items in an array if a numeric keys are used. The array can contain strings, number or objects. Access array at index 1 {% {array_with_strings}[1] %} => "test_2" Access array at index 1 and display value of "item" {% {array_with_objects}[1]["item"] %} => "test_2" || Object keys must be wrapped with double quotes, while numeric array keys should not be. Example JSON { "array_with_objects": [PopularList (array) functions
Count It is possible to count number of items in list. {% count({line_items}) > 3 ? 'More than three' : 'Less than three' %} Max Returns maximum value of list of elements or separate field values. {% max({line_items::quantity}) %} or {% max({dataField1}, {dataField2}, ..., {dataFieldN}) %} Min Returns minimum value of list of elements or separate field values. {% min({line_items::quantity}) %} or {% min({dataField1}, {dataField2}, ...,PopularNumber Functions
Format number Format a number with grouped thousands and optionally decimal digits. {% number_format([float number], [decimal_places], [decimal_separator], [thousands_separator]) %} Round Round the float number based on the precision from the second parameter. {% round([float number], [integer precision]) %} Ceil Rounds to the nearest integer up. E.g. 2.1 => 3. {% ceil ([float number]) %} Floor Rounds to the nearest integer down. E.g. 2.8 =>Some readersString functions
Uppercase To display data field value in uppercase, use following expression. {% uppercase({dataFieldName}) %} Lowercase To display data field value in lowercase, use following expression. {% lowercase({dataFieldName}) %} Capitalize Uppercase the first character of each word in a string. {% capitalize({dataFieldName}) %} Split The split(delimiter, string) function allows to split string into an array. {% split("_", "Some_string") %}PopularSupported operators
Arithmetic Operators + (Addition) {% 2 + 3 %} >> 5 - (Subtraction) {% 7 – 4 %} >> 3 * (Multiplication) {% 2 * 3 %} >> 6 / (Division) {% 9 / 3 %} >> 3 % (Modulus) {% 10 % 3 %} >> 1 ** (Pow) {% 5 ** 2 %} >> 25 Logical Operators ! (not) {% !true ? "true": "false" %} >> false && (And) {% true && false ? "true": "false" %} >> false || (Or) {% true || falsePopularUtility functions
Empty The empty(value) checks if the variable exists and if the value is not “falsy”. Returns true if var does not exist or has a value that is empty or equal to zero, aka falsely. Otherwise, it returns false. {% empty({dataField}) ? 'No value' : 'Field has value' %} What qualifies as "falsy"? Anything that returns false if cast to boolean Empty array Zero as number Zero as string Empty string null false undefined JSON decode Decode JSON string to usPopularWhat is Expression Language?
Expression language in PDF Generator API is a specific programming language that allows writing mathematical and logical expression to manipulate the value displayed by component. Example expression Use-case of the array functions | Tip: Use the Number Component or apply "Number" formatting within tables, when creating calculations or using functions like sum, average and sumproduct. Related articles you mayPopular
