In this guide, we will explain how to achieve Date/Currency/Number formatting and conditional statements usage in PDF with the help of the PDF helper function.
To go to the PDF Editor page, click on the "Action" drop-down corresponding to the form name from the Formyoula Dashboard.
Scroll down the page and click on Page Settings.
Enable Advanced Templating from the PDF Editor Settings before trying the below examples.
Using toFixed helper to format a number.
To fix a decimal value up to 2 point we can use toFixed helper with option 2.
value of component_id = 1.1234566
{{toFixed component_id 2}}
Output: 1.12
Or for decimal up to 3 use below
{{toFixed component_id 3}}
Output: 1.123Using toCurrency to format a number/digit based on different options
For more details on currency formatting and options, please visit the following link:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toLocaleString
Using eval to format a date/number/digit or to perform any mathematical calculations
Using AND and OR ( && and || ) in PDF editor:
Using AND-
<!--{{#compare component_id_2 Â component_id_1 operator="&&"}} -->
//Show this only if both values are available
<!--{{/compare}} -->
Using OR-
<!--{{#compare component_id_2 Â component_id_1 Â operator="||"}} -->
//Show this if any one value is available
<!-- {{/compare}} -->Using > and < operators in the PDF editor
PDF Editor supports the following operators.
==, ===, !=, <, >, <=, >=, && and ||
I.e.
{{#compare component_id_2 "0" operator=">"}}
{{/compare }}
{{toFixed component_id 2}}For any questions, please contact us - [email protected] or the Formyoula in-app chat 🙂