Skip to main content
Skip table of contents

.iText DITO Editor - Calculations viText_DITO_2.2

In order to simplify the processing of data without the need for pre-processing, iText DITO can handle many straightforward and even more complex calculations.

Inserting a Calculation

Calculations can be inserted into rich text elements. To insert a calculation, click the f(x) icon in the command bar.

Bear in mind that it can be hidden under the vertical ellipsis (three vertical dots) icon.

Straightforward Calculations

iText DITO supports the following functions:

sum()calculates the sum of the arguments

sum({{field1}}+{{field2}}) or sum({{field1}}-{{field2}}) 

product()calculates the product of the arguments

product({{field1}}*{{field2}}) or product({{field1}}/{{field2}})

concat()concatenates text stringsconcat({{first_name}},' ',{{last_name}})
size()calculates the number of items in an arraysize({{items}})
numberToText()converts a numerical value into a text string. Optionally you can add a locale.numberToText({{numerical_field}}, 'en-us')
moneyToText()converts a numerical value to a text string, with a currency name. moneyToText({{numerical_field}}, 'en-us')

And the following operators:

"+": Addition

"-": Subtraction

"*": Product/Multiplication

"/": Division


Imagine you are designing a report on consumption of service hours. The customer has a certain entitlement of support hours and has consumed some of those. Your report should calculate the total amount due for the hours consumed and the remainder of the entitlement. The data contains only these fields:

{{service_hour_entitlement}}, {{service_hour_consumption}}, {{service_hour_unit_price}}

To calculate the total amount due, you can use the product() function

Calculations within Loops

All of the straightforward calculations can be used inside a repeatable element, like a table row that repeats for all items on an invoice template. In that case make sure to use relative references to the data elements.

More Complex Calculations

It is also possible to calculate a field using other fields which are the results of calculations themselves. In order to perform calculations on the variables in a field, you must name the fields. The field names act as variables that you can use in mathematical expressions.


In the example below the aim is to calculate a grand total based on calculated subtotals.

First, create a table with repeating rows for each item in an array. In the last cell of the row, insert a rich text element with a product() calculation. 

To be able to use that product() in another calculation, give the rich text element a name.

You can now use this name in other calculations, for instance to calculate the grand total. Note that you don't use double curly braces to refer to this named field. The double curly braces are only used to refer to elements in the data sample. 

Checking value for 'Null'

Calculations support the possibility of checking value for 'null' in conditional visibility, and is available in the syntax mode. 

Our team has implemented a "_filterNotNull()_" function which will ignore nulls while calculating size, so the expression "_size(filterNotNull(\{{leafField[*]}})) != 0_" will be false in case leafField is null.

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.