Skip to main content
Participating Frequently
July 18, 2019
Answered

Concatenate Fields with Bold Text

  • July 18, 2019
  • 1 reply
  • 1405 views

Hello.  I am using Adobe Acrobat XI Pro and am creating a form which concatenates several text fields into one.  Some of the text needs to be in a bold font and the rest are not.  I am using a Custom Calculation Script as follows:

// Get the field values, as strings

var s1 = getField("Paragraph1").valueAsString;

var s2 = getField("FName").valueAsString;

var s3 = getField("LName").valueAsString;

var s4 = getField("DateIssued").valueAsString;

var s5 = getField("Paragraph2").valueAsString;

// Combine values, separated by a space

event.value = s1 + " " + s2 + " " + s3 + " on " + s4 + ".  " + s5;

I would like the text fields "FName" and "LName" to be bold, but the rest are not.  I have tried searching this and can not find a resolution to my question.  Can someone help please?  Thank you.

This topic has been closed for replies.
Correct answer try67

You can do it by defining the field as having Rich Text Formatting (under Properties, Options), but then the script has to be amended to the following:

var s1 = getField("Paragraph1").valueAsString;

var s2 = getField("FName").valueAsString;

var s3 = getField("LName").valueAsString;

var s4 = getField("DateIssued").valueAsString;

var s5 = getField("Paragraph2").valueAsString;

var spans = [];

var span1 = {};

span1.text = s1 + " ";

spans.push(span1);

var span2 = {};

span2.text =  s2 + " " + s3;

span2.fontWeight = 700

spans.push(span2);

var span3 = {};

span3.text = " on " + s4 + ".  " + s5;

spans.push(span3);

event.richValue = spans;

1 reply

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
July 18, 2019

You can do it by defining the field as having Rich Text Formatting (under Properties, Options), but then the script has to be amended to the following:

var s1 = getField("Paragraph1").valueAsString;

var s2 = getField("FName").valueAsString;

var s3 = getField("LName").valueAsString;

var s4 = getField("DateIssued").valueAsString;

var s5 = getField("Paragraph2").valueAsString;

var spans = [];

var span1 = {};

span1.text = s1 + " ";

spans.push(span1);

var span2 = {};

span2.text =  s2 + " " + s3;

span2.fontWeight = 700

spans.push(span2);

var span3 = {};

span3.text = " on " + s4 + ".  " + s5;

spans.push(span3);

event.richValue = spans;

JB5602Author
Participating Frequently
July 18, 2019

Thank you for sending this out.  I am not sure if I did something wrong, because my fields are no longer combining and the names did not bold.  I did go to options and change the setting to Allow Rich Text Formatting.  Any suggestions?

try67
Community Expert
Community Expert
July 18, 2019

Did you place the script as a custom calculation script?

Are there any error messages in the console window?