Fix HTML Markup Showing in Rich Text PDF Form Fields
Question details
The user is attempting to format text inside a fillable PDF form field using HTML tags, but the field fails to render the formatting and instead displays the raw HTML code.

- Product
- PDF Editor
- Device & OS
- not provided
- Scenario
- Filling out or populating a PDF form field that has rich-text formatting enabled.
- Observed behavior
- The form field displays raw HTML tags like <p> and <span> instead of rendering the formatted, colored text.
Verify that the PDF form field you are working with actually has rich-text formatting enabled in its properties before attempting to apply any script-based or manual styling.
Use PDF JavaScript for Rich Text Formatting
Since PDF form fields do not natively interpret HTML markup, you must use standard JavaScript rich-text arrays (span objects) to format text dynamically.
PDF readers do not function like web browsers, meaning standard HTML tags like <p>, <b>, or <span> will be rendered as literal text strings. To format text inside a rich-text field programmatically, you must utilize the specific rich-text properties defined in the Acrobat JavaScript API.
Open your PDF editor in Form Editing mode, right-click the target field, and select 'Properties'.
Navigate to the 'Options' tab and ensure the 'Allow Rich Text Formatting' checkbox is ticked.
Instead of passing an HTML string to the field, write a script to assign a structured rich-text array to the field's `richValue` property to set text color, font weight, and size.

Apply Formatting Manually Using the Properties Toolbar
If you do not need to populate the field programmatically via scripts, you can format the entered text manually using the built-in rich text UI tools.
Edit and Format PDF Form Fields Easily with WPS Office
WPS PDF provides intuitive tools to create, edit, and fill interactive PDF forms. You can easily enable rich text formatting and customize field appearances visually without writing complex HTML or JavaScript.
- 1. Open your PDF form: Launch WPS Office, select the 'PDF' tab, and open your form document.
- 2. Access form tools: Navigate to the 'Form' tab on the top ribbon to access interactive form creation and editing tools.
- 3. Customize fields visually: Right-click any text field, select 'Properties', and easily customize text formatting, colors, and layouts using the graphical interface.

Frequently Asked Questions
Why isn't my HTML code working in a PDF text field?
PDF form fields do not contain web browser rendering engines. Any HTML tags entered into a field are treated as literal text strings and displayed exactly as typed instead of being rendered into formatted text.
How can I change the text color in a fillable PDF field?
If the form creator enabled 'Rich Text Formatting' for that field, you can highlight the text and press Ctrl+E (Windows) or Cmd+E (Mac) to open the formatting toolbar, which allows you to change colors, fonts, and sizes.
Can I populate a rich-text PDF field using a script?
Yes, you can populate it dynamically using JavaScript. However, instead of passing HTML strings, you must define an array of rich-text span objects and assign it to the field's richValue property.




