How to Dynamically Bold and Underline Text in PDF Form Fields
Question details
The user wants to apply mixed inline formatting, such as bolding specific words and underlining an email address, to a paragraph generated by a script inside a PDF form field.

- Product
- Adobe Acrobat
- Device & OS
- not provided
- Scenario
- Automatically populating PDF form fields using scripts where certain parts of the text require distinct visual formatting.
- Observed behavior
- Standard PDF form fields default to plain text and do not support mixed inline formatting when populated via basic scripts.
Ensure you have editing permissions for the PDF form, as you will need to modify the properties of the target text fields to support advanced formatting.
Enable Rich Text Formatting in Form Fields
Modify the form field properties to allow rich text, which is required if you want to apply mixed formatting like bold and underline dynamically.
By default, standard PDF form fields are strictly plain text. To mix bold, italic, or underlined text within the same field, you must enable the Rich Text property. Keep in mind that once enabled, any JavaScript used to populate the field must be rewritten to generate valid rich-text span objects (XML) instead of standard plain text strings.
Open your PDF form in Adobe Acrobat or a capable PDF editor and switch to the 'Prepare Form' or 'Form Editing' mode.
Right-click the specific text field you want to format and select 'Properties' from the context menu.
Navigate to the 'Options' tab in the Properties window and check the box labeled 'Allow Rich Text Formatting'.
Modify your script to output rich text XML format. Instead of a simple string assignment, use the richValue property of the field to pass an array of span objects containing your specific bold and underline attributes.

Format Content Before Converting to PDF
If writing rich text XML scripts is too complex, format the document in a standard word processor before converting it to a static PDF.
Create and Format PDFs Easily with WPS Office
Instead of struggling with complex JavaScript arrays for PDF form fields, use WPS Office to effortlessly draft your documents with perfect bold, underline, and rich text formatting. You can then seamlessly export them to high-quality PDFs in seconds.
- 1. Create your document: Open WPS Writer and start a new blank document, or open your existing template.
- 2. Apply text formatting: Type out your paragraph. Highlight specific words and use the top toolbar to easily apply bold, italics, or underline formatting.
- 3. Export to PDF: Click on 'Menu' in the top-left corner, select 'Export to PDF', choose your save location, and click 'Export' to generate a beautifully formatted PDF.

Frequently Asked Questions
Can standard PDF text fields contain mixed formatting?
No, standard PDF text fields are designed exclusively for plain text. To use mixed formatting, such as bolding only specific words in a sentence, the field must have the 'Allow Rich Text Formatting' property explicitly enabled.
How do I underline an email address in a PDF script?
If the form field is plain text, you cannot selectively underline parts of it. If rich text is enabled, your script must pass a rich-text array containing a span with a text-decoration attribute applied to the email address, rather than passing a simple text string.
Can an automated email sent from a PDF script contain formatted HTML?
Native Acrobat mailto scripts only generate plain-text emails. To send HTML formatted emails featuring bold or underlined text, you cannot rely solely on the PDF; you must use a custom server-side script or an external HTML email workflow.
Is there an easier way to create formatted forms without scripting?
Yes. Designing the layout and text formatting directly in a word processor (like WPS Writer) before exporting to PDF is much simpler and more reliable than relying on JavaScript for dynamic rich text rendering.




