These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Bold one word in a dynamic string

Guy76
Registered: Jun 11 2007
Posts: 2

Hi,

I'm populating acrofields from a database and would like to bold just one word of a text string. Is there any way of tagging this word so that it appears bold while the rest of the string stays regular?

gkaiseril
Online
Expert
Registered: Feb 23 2006
Posts: 4307
You will have to use the "span" object to create an array element for each substring of text with different properties.

For example:

var f = this.getField("myRichField");
// Create an array to hold the Span objects
var spans = new Array();
// Each Span object is an object, so we must create one
spans[0] = new Object();
spans[0].alignment = "center";
spans[0].text = "The answer is x";
spans[1] = new Object();
spans[1].text = "2/3";
spans[1].superscript = true;
spans[2] = new Object();
spans[2].superscript = false;
spans[2].text = ". ";
spans[3] = new Object();
spans[3].underline = true;
spans[3].text = "Did you get it right?";
spans[3].fontStyle = "italic";
spans[3].textColor = color.red;
// Now assign our array of Span objects to the field using
// field.richValue
f.richValue = spans;

George Kaiser