The DataScope PDF Editor is a powerful tool that allows you to efficiently customize and configure your reports. In this guide, we will explain some functions and tips to help you get the most out of this feature.
📌 Setting Up and Using the Custom PDF Editor
How do I access the PDF Editor?
Go to Forms > Configure > Configure PDF > Custom PDF.
Click the "Open PDF Editor" button.
📌 PDF Editor Structure
Available components: on the left side, you will find tools such as text, tables, barcodes/QR codes, headers, footers, and more.
Component properties: on the right side, you can customize each selected element.
📌 How to add and link components
Add a component: drag the desired element to the appropriate position in the document.
Link data:
Double-click the component.
Select "Insert Data Field" and choose the corresponding question or field.
Main fields:
name: question name.value: answer entered in the form.
💡 Pro tip: data must be structured between {% %}. For example:
{% {variable_aqui::value} %}
📌 Main PDF Editor Functions
Transforming empty values:
Empty values are displayed as a
-. You can use this logic to configure functions that transform an empty value into a specific value.Example: to display alternative text when a field is empty, use:
{% {variable_aqui::value}=='-' ? 'Texto alternativo' : {variable_aqui::value} %}
Configuring Repeatable Questions:
In repeatable questions, variables from
_5onward must use theemptyfunction to handle empty values.{% empty({variable_aqui::value}) ? ' ' : {variable_aqui::value} %}
Hiding Empty Pages:
Task Assigner:
Variables available when assigning tasks:
Address
Legal company code
Legal company name
Unique location code
Location description
📌 Common Functions
Displaying specific values
To display a value based on a condition:
{% {variable aquí::value}=='Si' ? 'x' : ' ' %}To display a value when there is no answer:
{% {variable aquí::value}=='-' ? 'Texto por defecto' : {variable aquí::value} %}To handle empty fields:
{% empty({variable aquí::value}) ? ' ' : {variable aquí::value} %}
2. Mathematical operations
Adding values when there are empty answers (
-):{% ({variable aquí::value}=='-' ? 0 : {variable aquí::value}) + ({variable 2 aquí::value}=='-' ? 0 : {variable 2 aquí::value}) … + ({variable n aquí::value}=='-' ? 0 : {variable n aquí::value}) %}Average of 2 variables:
{% (({variable aquí::value}=='-' ? 0 : {variable aquí::value}) + ({variable 2 aquí::value}=='-' ? 0 : {variable 2 aquí::value})) / (2) %}Denominator condition when there are no answers:
{% {variable aquí::value}=='-' ? 0.00001 : 1 %}This is used to prevent the denominator from being 0 when there are no answers (when the value is
'-'). The minimum denominator value will be0.00001when there is no answer.Conditional average calculation between 2 variables (only if both answers exist):
{% (({variable aquí::value}=='-' ? 0 : {variable aquí::value}) + ({variable 2 aquí::value}=='-' ? 0 : {variable 2 aquí::value})) / (({variable aquí::value}=='-' ? 0.00001 : 1)+ ({variable 2 aquí::value}=='-' ? 0.00001 : 1)) %}This calculation works as follows:
If one of the variables has no answer (is
'-'), it is treated as0instead of a null value.For the denominator, if any variable has no answer,
0.00001is used to prevent division by zero.It is important to use this decimal value because using
0directly in the division without taking this rule into account will result in a division-by-zero error.
Adding and multiplying elements when there is no answer (
'-'):If you want to perform calculations with multiple elements and consider
0when there is no answer ('-'), you can use the following formula:{% (({variable aquí::value}=='-' ? 0 : {variable aquí::value}) * ({variable 2 aquí::value}=='-' ? 0 : {variable 2 aquí::value}) * ({variable 3 aquí::value}=='-' ? 0 : {variable 3 aquí::value}) … + ({variable n aquí::value}=='-' ? 0 : {variable n aquí::value}) %}This example performs a multiplication of several variables. If any variable has no answer (
'-'), it is replaced with0to prevent errors.
Pay attention to the parentheses, as they are very important for treating the entire expression as a single value and preventing language errors.
3. Dates and times
Current date:
{% date('now') %}Custom date format:
{% date({Variable aquí}, 'UTC', 0, 'd/m/Y') %}Convert a form variable into a specific format:
{% date({created_at}, 'UTC', 0, 'd/m/Y') %}Convert minutes to hours:
{% floor({minutos_variable}/60) %} horas, {% (({minutos_variable}/60) - floor({minutos_variable}/60)) * 60 %} minutosTime in hours and minutes:
{% floor((({Variable tiempo aquí::value})/60) %}:{%(((({Variable tiempo aquí::value})/60)-floor((({Variable tiempo aquí::value})/60))*60 %}Format a date variable in dd/mm/yyyy format as "10 of April of 2023":
{% split('-',{k_FechaHora 5_5::value})[0] %} de {% split('-',{k_FechaHora 5_5::value})[1] =='01' ? 'Enero' : split('-',{k_FechaHora 5_5::value})[1] =='02' ? 'Febrero' : split('-',{k_FechaHora 5_5::value})[1] =='03' ? 'Marzo' : split('-',{k_FechaHora 5_5::value})[1] =='04' ? 'Abril' :split('-',{k_FechaHora 5_5::value})[1] =='05' ? 'Mayo' :split('-',{k_FechaHora 5_5::value})[1] =='06' ? 'Junio' : split('-',{k_FechaHora 5_5::value})[1] =='07' ? 'Julio' : split('-',{k_FechaHora 5_5::value})[1] =='08' ? 'Agosto' : split('-',{k_FechaHora 5_5::value})[1] =='09' ? 'Septiembre' : split('-',{k_FechaHora 5_5::value})[1] =='10' ? 'Octubre' : split('-',{k_FechaHora 5_5::value})[1] =='11' ? 'Noviembre' : split('-',{k_FechaHora 5_5::value})[1] =='12' ? 'Diciembre' : ' ' %} del {% split('-',{k_FechaHora 5_5::value})[2] %}Add days to a date:
{% date ({k_Fecha_2_2::value}, 'UTC' ,27, 'd/m/Y' ) %} This adds 27 days to the date.Get the difference between two times in minutes:
{% empty(split(":",{k_Hora fin_12_17::value})[1]) || empty(split(":",{k_Hora inicio_12_15::value})[1]) ? '-' : 1440*(split(":",{k_Hora fin_12_17::value})[0] < split(":",{k_Hora inicio_12_15::value})[0]) + (split(":",{k_Hora fin_12_17::value})[0] - split(":",{k_Hora inicio_12_15::value})[0])*60 + split(":",{k_Hora fin_12_17::value})[1] - split(":",{k_Hora inicio_12_15::value})[1] %}
4. Signatures and Images in HTML
Photos as HTML (for use in tables):
<p><img src="{foto_aqui::value}" width="80" height="100"></p>Signatures as HTML (for use in tables):
<p><img src="{firma_aqui::value}" width="80" height="100"></p>Leave a description empty when there is no image in a repeatable question under
_4 (Repetition 5):Using a condition to check whether the variable has the value
'-'(no image):
{% {variable aquí::value}=='-' ? ' ' : 'photo description' %}In this case, if there is no image (value
'-'), an empty description (' ') will be displayed.2. Using the
emptyfunction to check whether the variable is empty:{% empty({variable aquí::value}) ? ' ' : 'photo description' %}Here, if the variable is empty (no image), an empty description will also be displayed.
📌 Advanced Tips
Nested Conditions
Use
&for "and" and|for "or":{% ({variable_1::value} + {variable_2::value}) <= 3 & ({variable_2::value}) >= 1 ? 'Aceptado' : 'Rechazado' %}Display GPS
Display a static map with GPS coordinates:
https://maps.googleapis.com/maps/api/staticmap?size=700x700&maptype=roadmap&markers=icon:https://www.mydatascope.com/assets/favicon.ico%7Csize:mid%7Clabel:1%7C{k_Descripcin_9_9::latitude},+{k_Descripcin_9_9::longitude}&visible={k_Descripcin_9_9::latitude},+{k_Descripcin_9_9::longitude}&zoom=15&key=AIzaSyB39JUuV_2N_2i-bh6tzAfPcEWxeUh777c
Related List Separator:
If you need to split a value using a separator, you can use the following code:
{% split('-',{variable aquí::value})[0] %}The number
0indicates the position of the text before the selected separator. To obtain the text after the separator, you can change the index (for example,[1]).
Split within Split (2):
If you need to use a
splitinside anothersplit, use the following example:{% split(':',{split('|',{variable aquí::value})[2] })[1] %}This first splits the variable using the
|separator, then selects the third element (index[2]), and finally splits that element again using:.
Split within Split (3):
If you need to use a
splitinside anothersplitin a more complex way, use this code:{% split(‘-’,{split(':',{split('|',{variable aquí::value})[2] })[1]})[1] %}This example performs multiple splits on the variable: first using the
|separator, then:, and finally-.
Using HTML to Display Images:
If you want to display an image inside HTML using a
split, use this code:<p><img src="{split(':',{split('| ',{assign_description})[16] })[1]}" width="80" height="100"></p>This example splits the value of
{assign_description}, takes the 17th element (index[16]), and then displays an image using the resultingsrc.
Displaying a Download Link for an Attachment:
If you want to include a link that allows users to download an attached file, you can use the following HTML code:
<p><a href="{k_Adjuntar Archivo 0_247::value}">Download Attached File 1</a></p>This code creates a link that allows users to download the file linked to the
{k_Adjuntar Archivo 0_247::value}variable. The link text will be "Download Attached File 1".
Pro Tip 💡
If you need to include conditions in your custom reports, you can use conditional expressions such as:
{% {variable aquí::value}=='Si' ? 'x' : ' ' %}This works as follows:
?: defines the result when the condition is true (for example, displays'x'if the variable equals"Yes").:: defines the result when the condition is false (for example, displays a blank space if the variable is not"Yes").
Practical example:
{% {variable::value}=='Si' ? 'Aprobado' : 'Pendiente' %}If the answer is
"Yes", it will display "Approved".Otherwise, it will display "Pending".
Use this logic to create dynamic and clear reports!
📌 Best Practices
Validate your code: always test functions in a test environment before implementing them in production.
Use parentheses correctly: make sure expressions are properly grouped to avoid errors.
Configure conditional formatting: simplify the display by hiding unnecessary elements.
Save your changes regularly: make sure to save all changes before closing the session or switching screens, as there is no undo option (Ctrl+Z).
Avoid using Ctrl+Z: since it does not work to undo actions, it is essential to save frequently.
Use only one tab while working in the editor: to avoid conflicts or data loss, it is recommended to keep only one tab open while working in the editor.
For more information or assistance, contact us through our support chat.



