PDF Editing Issues

Italicize Part of a Form Field in an Acrobat Script

Adam DavisAdam Davis Nov 19, 2026 868 views

Question details

The user wants a form script to italicize only part of the text placed in a field for one switch case.

Italicize Part of a Form Field in an Acrobat Script
Product
Adobe Acrobat forms
Device & OS
not provided
Scenario
A switch statement assigns different text to a form field, and the second case needs partial italic formatting.
Observed behavior
The desired field value contains both regular and italic text in the second case.
Before you start

Confirm whether the PDF is a standard Acrobat form or a LiveCycle Designer/AEM XFA form, and identify the target field's name. The rich-text method below applies to supported Acrobat form fields, not XFA fields.

Solution 1Recommended

Use rich-text spans in an Acrobat form field

Use this approach for a standard Acrobat form when the target text field supports rich-text formatting.

A plain field value does not specify formatting for individual words. A rich-text value can contain separate spans with different formatting properties.

1
Enable rich text

In Acrobat, open All tools > Prepare a form, double-click the target text field, and look under Options for Allow Rich Text Formatting. Enable it if available.

2
Edit the relevant script

Open the action or field script containing the switch statement. In the second case, get the target field with this.getField("FieldName"), replacing FieldName with the actual field name.

3
Assign formatted spans

In that case, assign a rich-text value instead of a plain string. For example: this.getField("FieldName").richValue = [{text: "Regular text "}, {text: "italic text", fontStyle: "italic"}, {text: " regular text"}]; Keep the case's break statement after the assignment.

4
Test the result

Use Preview in Prepare a form, trigger the second case, and check that only the intended span is italic. Test the other cases as well, since a later assignment to the field can replace its formatting.

Use rich-text spans in an Acrobat form field
XFA forms use a different method: If the PDF is a LiveCycle Designer or AEM XFA form, use its supported rich-text field and scripting features instead. Acrobat form-field richValue examples should not be assumed to work in XFA.
Free Microsoft Office alternative

Edit PDF Content and Office Files with WPS Office

WPS Office is a free, lightweight alternative with a familiar interface and support for common Office formats, making it easy to move everyday document work. Its PDF editing tools can help with static text, but they do not replace Acrobat's form scripting.

Edit and format static PDF text where supportedOpen and work with Microsoft Word, Excel, and PowerPoint formatsUse a familiar interface for everyday document tasksMove between PDF and Office document workflows in one suite
microsoft office alternative - wps office

Frequently Asked Questions

Can I italicize one word by assigning a plain string to the field?

A plain string does not carry separate formatting for individual words. In a supported Acrobat rich-text field, assign spans through the field's richValue property instead.

Where do I enable rich text for an Acrobat form field?

Open All tools > Prepare a form, double-click the text field, and check the Options tab for Allow Rich Text Formatting. The option depends on the field and form type.

Will the Acrobat richValue example work in a LiveCycle Designer form?

Do not assume it will. LiveCycle Designer and AEM XFA forms use different form and scripting technologies, so check the XFA field's supported rich-text methods.

What should I check if the italic text does not appear?

Confirm that rich-text formatting is enabled, the script targets the correct field, and the second switch case runs. Also check whether another script later assigns a plain value to the same field.