• PDF Generator API
    • File
      • New
      • Open
      • SaveCtrl+S
      • Rename
      • Make a copy
      • Remove
      • Export
      • Import
      • PreviewCtrl+P
      • Download as
        • PDF
        • HTML
        • HTML (Web page)
        • MS Excel
      • Page setup
      • Template settings
      • Data settings
    • Edit
      • UndoCtrl+Z
    • View
      • PreviewCtrl+P
      • EditorCtrl+E
      • Data
      • Component list
      • Grid view
        • None
        • 0.5 cm
        • 1 cm
    • Insert
      • Page
      • Data
    • Help
      • Expression functions
      • Workspace information
      • Support portal
    •   ENG
      • English
      • Eesti keeles
      • Slovensky
      • Česky
      • русский
      • Deutsche
 

Expression Language Functions

Expression language is PDF Generator API specific programming language that allows to write mathematical and logical expression to manipulate the value displayed by component.

{% 2 + {dataFieldName} + {dataFieldName2}*0.5 %}

Supported operators

1. Arithmetic Operators

  • + (addition)
  • – (subtraction)
  • * (multiplication)
  • / (division)
  • % (modulus)
  • ** (pow)
2. Bitwise Operators
  • & (and)
  • | (or)
  • ^ (xor)
3. Comparison Operators
  • == (equal)
  • === (identical)
  • != (not equal)
  • !== (not identical)
  • < (less than) > (greater than)
  • <= (less than or equal to) >= (greater than or equal to)
  • matches (regex match) e.g {% {dataField} matches "/bar/" ? "yes" : "no" %}
4. Array
  • in (contain)
  • not in (does not contain)
5. String
  • ~ (concatenation)

Ternary Operators

{% {financial_status} === 'paid' ? 'All paid' : 'Waiting for payment' %}

{% {financial_status} === 'paid' ? uppercase({financial_status}) : 'Waiting for payment' %}

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}) %}

Example: {% capitalize('hello word') %} => Hello Word


Sum

It is possible to calculate sum of table column using following code
{% sum({line_items::amount}) %}


Sumproduct

The sumproduct function multiplies the corresponding items in the arrays and returns the sum of the results.
{% sumproduct({line_items::amount},{line_items::price}, {line_items::anotherColumn}) %}


Average

It is possible to calculate average of table column using following code
{% avg({line_items::amount}) %}


Count

It is possible to count number of items in list
{% count({line_items}) > 3 ? 'More than three' : 'Less than three' %}


Empty

The empty function checks if field has value.
{% empty({dataField}) ? 'No value' : 'Field has value' %}


Join

The join(delimiter, array) function concatenates field values with specified separator. Last arguments is always used as the separator.
{% join(";", {field1}, {field2}, {field3}, ..., {fieldN}) %}


Split

The split(delimiter, string) function allows to split string into an array
{% split("_", "Some_string") %} => ["Some", "string"]


Date

Format date value. NB! You need to use the Date formatter.
{% date({dateString}, {timezone}, {addDays}, {outputFormat}, {inputFormat}) %}

Examples:
Display current time - {% date('now') %}
Specify timezone - {% date({dateValue}, 'UTC') %}
Specify output format - {% datetime({dateValue}, 'UTC', 0, 'd/m/Y') %}
Specify output and input format - {% datetime({dateValue}, 'UTC', 0, 'd/m/Y', 'm/d/Y') %}

Format Description Example
Day
d Day of the month, 2 digits with leading zeros 01 to 31
D A textual representation of a day, three letters Mon through Sun
j Day of the month without leading zeros 1 to 31
l A full textual representation of the day of the week Sunday through Saturday
Month
F A full textual representation of a month, such as January or March January through December
m Numeric representation of a month, with leading zeros 01 through 12
M A short textual representation of a month, three letters Jan through Dec
n Numeric representation of a month, without leading zeros 1 through 12
Year
Y A full numeric representation of a year, 4 digits Examples: 1999 or 2003
y A two digit representation of a year Examples: 99 or 03
Timezone
O Difference to Greenwich time (GMT) in hours Example: +0200
P Difference to Greenwich time (GMT) with colon between hours and minutes (added in PHP 5.1.3) Example: +02:00
T Timezone abbreviation Examples: EST, MDT ...
Z Timezone offset in seconds. The offset for timezones west of UTC is always negative, and for those east of UTC is always positive. -43200 through 50400


Datetime

Format datetime value. NB! You need to use the Date formatter.
{% datetime({datetimeString}, {timezone}, {addDays}, {outputFormat}, {outputFormat}) %}

Examples:
Display current time - {% datetime('now') %}
Specify timezone - {% datetime({dateValue}, 'UTC') %}
Specify output format - {% datetime({dateValue}, 'UTC', 0, 'd/m/Y H:i:s') %}

Format Description Example
Time
a Lowercase Ante meridiem and Post meridiem am or pm
A Uppercase Ante meridiem and Post meridiem AM or PM
G 24-hour format of an hour without leading zeros 0 through 23
h 12-hour format of an hour with leading zeros 01 through 12
H 24-hour format of an hour with leading zeros 00 through 23
i Minutes with leading zeros 00 to 59
s Seconds with leading zeros 00 through 59


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}, ..., {dataFieldN}) %}


Round

Returns the rounded value to specified precision.
{% round({value}, 2) %}

Examples:
{% round(10.123, 2) %} // 10.12


Ceil

Returns the next highest integer value by rounding up value if necessary.
{% ceil({value}) %}

Examples:
{% ceil(10.3) %} // 11


Floor

Returns the next lowest integer value by rounding down value if necessary,
{% floor({value}) %}

Examples:
{% ceil(10.3) %} // 10


Pow

Returns base raised to the power of exp.
{% pow({base}, {exp}) %}

Examples:
{% pow(2, 3) %} // 8


Sqrt

Returns the square root of value.
{% sqrt({value}) %}

Examples:
{% sqrt(4) %} // 2


Iterate list of elements (array map)

Iterates over list of elements and executes expression for each element. Returns new list.
{% iterate({line_items}, 'quantity*price') %}


Iterate list of elements (array map)

Iterates over list of elements and executes expression for each element. Returns new list.
{% iterate({line_items}, 'quantity*price') %}


Collect unique values from list

Collects unique values from and counts them. Returns new list with following structure: [{"value": "Value", "count": 3, "raw_value": "Value"}, {"value": "Value 2", "count": 1, "raw_value": "Value 2"}]
{% collect_unique_values({array}, {array_of_values_to_exclude}, {expression_to_execute_for_each_item}) %}


Filter list of elements (array map)

Filters a list of elements by executing the given expression for each element. Returns new list.
{% filter({line_items}, 'price > 10.1') %}


Collect unique values from list

Collects unique values from and counts them. Returns new list with following structure: [{"value": "Value", "count": 3, "raw_value": "Value"}, {"value": "Value 2", "count": 1, "raw_value": "Value 2"}]
{% collect_unique_values({array}, {array_of_values_to_exclude}, {expression_to_execute_for_each_item}) %}


Flatten list

Flattens list.
{% flatten(iterate({orders}, "{line_items}")) %}


JSON decode

Decode JSON string to use in an expression.
{% json_decode('{"key": "value"}', true) %}


Workspace information

AR Demo account

demo.example@actualreports.com