Skip to main content
Inspiring
May 24, 2020
Answered

Formatting only part of the output of a field in a PDF form.

  • May 24, 2020
  • 1 reply
  • 719 views

I am concatinating two fields with a text string using the following as a custom calculation:

event.value = "Words" + this.getField("D1").valueAsString + this.getField("F1").valueAsString;

 

Field F1 is actually a numeric value.    I would like to chnge the fomrattign of how F1 appears for readinility.  Something as simple as making it bold would be enough, but also increasing the font size would be good as well.

I do not want to change the formatting of "Words" or D1 so I don't think I can do with global formatting.

Is it possible because F1 is a number I could use soem conditional statment to bold only numbers in event.value?

This topic has been closed for replies.
Correct answer ls_rbls

Don't forget to mark this solution as correct answer.

1 reply

XML1979Author
Inspiring
May 25, 2020

Problem Solved by rjunke

 

Here is the solution provided that worked

 

"Try something like this:

Place the conditional script in the number field and have it output to the text field. You'll need to use an array() to get the conditional formatting you want.

I created a number field formatted as a number and created a text field with no formatting. In the number field I added this custom calculation script:

var v = this.getField("Number1").valueAsString;

var spans = new Array();

spans[0] = new Object();
spans[0].text = "Words: ";
spans[0].fontWeight = 400; // normal weight

spans[1] = new Object();
spans[1].text = v; // insert the value we read from the field
spans[1].fontWeight = 800; // bold

var f = this.getField("Text16");
f.richText = true; // make sure we are dealing with a rich text field
f.richValue = spans;

 

The array gets written to the text field as richtext.

 

Hope this helps."

ls_rbls
Community Expert
ls_rblsCommunity ExpertCorrect answer
Community Expert
May 26, 2020

Don't forget to mark this solution as correct answer.