Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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;
Copy link to clipboard
Copied
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;
Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
Did you place the script as a custom calculation script?
Are there any error messages in the console window?
Copy link to clipboard
Copied
I got it to work. Your code was spot on, I just fat fingered some stuff. Thank you
Find more inspiration, events, and resources on the new Adobe Community
Explore Now