The scripting capability that is available in eDocBuilder allows for using regular expressions to match patterns in text input in fields on your template. By using a combination of vbscript, regular expressions and html tags, you could selectively change the styling within a single field depending on if the text is letters or numbers.
The vbscript to match to upper and lowercase letters and make those characters red is shown below:
replaceregex(inputField, "(?i)([A-Z]+)", "<font color='0,100,50,00'>$1</font>")
The vbscript to match numbers and make them blue is shown below:
replaceregex(inputField, "([0-9]+)", "<font color='100,20,20,00'>$1</font>")
If you wanted to use both of these scripts on a single field, the composite statement would be:
ifs(choiceField = "Text", replaceregex(inputField, "(?i)([A-Z]+)", "<font color='0,100,50,00'>$1</font>"), "") & ifs(choiceField = "Numbers", replaceregex(inputField, "([0-9]+)", "<font color='100,20,20,00'>$1</font>"), "")
The composite statement above is more complicated in that it uses a field set for a dropdown with values of 'Text' and 'Numbers' as a choice, that tells the vbscript statements which formatting to apply. An demonstration can be seen on this example template
. The PDF file used for the composite example template can be downloaded here
You will notice, if you try the example template, that characters or numbers can be styled, but the styling does not apply to the punctuation marks in the example. That is also possible with regular expressions, but is more involved. It's easy enough to select numbers
, a little more involved to select characters
of upper or lower-case, but selecting different symbols requires a more detailed approach for the options
for the regular expression used on the field.
If you try the example scripts on this page, be sure to change the field references (inputField and choiceField) on the statements to be the name of the fields in your template, if you are not using the example PDF linked above.