Populate a Rich-Text Field from an Acrobat Drop-Down
Question details
Populate a PDF text field with differently formatted descriptions based on a drop-down selection.

- Product
- Adobe Acrobat PDF forms
- Device & OS
- not provided
- Scenario
- A PDF form should show a description with line breaks, colors, and font sizes that correspond to the selected drop-down option.
- Observed behavior
- The desired result is a rich-text description that changes when the user selects a different option.
Open the form in Adobe Acrobat with access to the Prepare a Form tool. Check the drop-down field name and its option export values, and decide which descriptions and formatting each value should produce.
Use an Acrobat calculation script to set rich-text spans
Use a custom calculation script on the destination text field when each drop-down option needs its own formatted description.
A drop-down export value identifies the selected option, but it does not carry the rich formatting for the destination field. The script can instead assign an array of formatted text spans to event.richValue.
In Acrobat, open Prepare a Form and double-click the drop-down. On the General tab, note its field name. On the Options tab, check the item and export values and enable Commit selected value immediately.
Double-click the destination text field in Prepare a Form. On its Options tab, enable Multi-line and Allow Rich Text Formatting so it can display formatted text and line breaks.
In the destination field's Properties dialog, open Calculate, select Custom calculation script, and click Edit. Enter the following example, replacing DescriptionChoice, Option A, and Option B with your field name and actual selection values: var choice = this.getField("DescriptionChoice").value; event.target.richText = true; if (choice === "Option A") { event.richValue = [ {text: "Option A\n", textSize: 16, textColor: color.red}, {text: "First description.", textSize: 11, textColor: color.black} ]; } else if (choice === "Option B") { event.richValue = [ {text: "Option B\n", textSize: 14, textColor: color.blue}, {text: "Second description.", textSize: 11, textColor: color.black} ]; } else { event.richValue = [{text: ""}]; }
Close the field properties, click Preview in Prepare a Form, and select each drop-down option. Confirm that the destination field updates and displays the intended line breaks, colors, and sizes.

Work with PDFs and Office files in WPS Office
WPS Office is a free, lightweight alternative with a familiar interface for working with PDFs and Office documents. Its format compatibility makes it easy to bring existing files into your workflow, although it does not replace the Acrobat scripting solution described above.

Frequently Asked Questions
Can a drop-down export value include rich formatting?
The export value identifies the selected option; it does not supply the destination field's rich formatting. Use a calculation script to map that value to formatted spans.
Where do I add the Acrobat script?
In Prepare a Form, open the destination text field's Properties, select the Calculate tab, and choose Custom calculation script. Click Edit to enter the script.
Why doesn't the description update when I select an option?
Check that Commit selected value immediately is enabled on the drop-down's Options tab. Also verify the field name and export values in the script, and make sure form calculations and JavaScript are enabled in the viewer.
How do I add a line break or change the text color?
In the script's span array, include \n in a span's text for a line break. Set textColor, such as color.red, and textSize on each span to control its appearance.
Will the form work in every PDF viewer?
Not necessarily. PDF viewers differ in their support for Acrobat JavaScript and rich-text fields, so test the saved form in the viewer your recipients will use.




