Multiple Formats In Fields With Rich Text Formatting
Formatting field values with rich text formats is very different from regular text field formatting
The font selection, size, and color in PDF form fields is generally limited to a single choice for each field. As a form designer, if you want certain words to stand out, you can choose bold or italic fonts and different sizes and colors. This is fine for different form fields that aren’t meant to flow together as a sentence or paragraph. But what if you have a multiline form field that pulls values from other fields in its calculated value for a summary, letter, or paragraph? And what if you want different formatting for different words or characters within that text? The first step is to select Allow Rich Text Formatting in the Options tab of the field properties.
After this selection you have two ways to format the text:
Once the field is filled in with text you can select different portions of text and format them with the Rich Text format toolbar.
Use JavaScript to set the contents and formatting of the field.
This article will describe the first method. The toolbar is usually not present. It can easily be displayed by selecting text in a field that is set to allow Rich Text formatting and then pressing Ctrl + e on the keyboard (Windows operating system).
Notice the four alignment settings: left, center, right, and both. Regular field alignment does not have the both alignment setting. Notice also the different options shown with T’s (bold, italic, strikethrough, superscript, subscript, and underline - with several options in the underline menu). None of these options are available with non-Rich field formatting (bold and italic are available as separate fonts for some fonts). Also notice the More… button.
Clicking More opens another window with a lot more options, including three vertical alignment options. Here’s a sample of what can be done inside one form field:
This type of field formatting is suitable for a non-interactive form field. In other words, a field that does not allow the user to edit the text, so the Read Only property should be set to true. If the field is reset it will lose the Rich Text formatting. In my next article I will outline how to format text with Rich Text formatting using a JavaScript calculation.
I don’t recall the properties for upper, middle, and bottom of a field (in properties of an array of Span objects or the Field property). I’m curious to see how that’s done in JavaScript. I look forward to the next entry.
Also, is there a way to specify a maximum or minimum font size? That is, you’re willing to change font size (as if you had specified font size 0, but it will stop at (say) point size 12?