PDF Editing Issues

How to Fix PDF Form Text Losing Bold Formatting After Editing

Natalie TaylorNatalie Taylor Nov 5, 2026 869 views

Question details

Users experience a loss of bold text formatting in PDF form fields when a calculation script overwrites manually entered rich text.

How to Fix PDF Form Text Losing Bold Formatting After Editing
Product
PDF Editors
Device & OS
not provided
Scenario
Filling out and attempting to format text in a calculated rich-text field within a PDF form.
Observed behavior
Bold formatting applied manually to the text disappears immediately after the user exits the calculated form field.
Before you start

Ensure that your PDF editor supports JavaScript and rich-text field properties, and verify that the specific form field is configured to allow rich text formatting in its properties.

Solution 1Recommended

Apply Bold Formatting Using JavaScript Span Objects

Since the calculation script overwrites manual formatting, you must define the bold style directly within the script using an array of Span objects.

When a field is set to calculate its value automatically, the calculation script takes complete control over the field's content. Because of this behavior, any manual rich-text formatting (like bolding text via keyboard shortcuts or toolbars) is discarded when the script updates the value.

To resolve this, you must instruct the PDF script to apply the formatting dynamically using the event.richValue property.

1
Access Field Properties

Open your PDF form in editing mode, right-click the target form field, and select 'Properties' from the context menu.

2
Open the Calculation Script

Navigate to the 'Calculate' tab in the Properties window, select 'Custom calculation script', and click the 'Edit' button to open the JavaScript editor.

3
Define the Span Object

Instead of setting a standard value, define an array of Span objects assigned to event.richValue. Set the text content and apply the bold style by setting the fontWeight property.

4
Apply the Code

Use a script format similar to: event.richValue = [{ text: 'Your Calculated Result', fontWeight: 800 }]; then click 'OK' to save and apply the script.

Apply Bold Formatting Using JavaScript Span Objects
Rich Text Requirement: The form field must have the 'Allow Rich Text Formatting' option enabled in its Options tab for the Span objects and event.richValue properties to function correctly.
Advanced PDF Editor

Create and Edit PDF Forms Seamlessly with WPS Office

WPS Office provides a comprehensive, user-friendly PDF editor that allows you to easily fill, edit, and manage PDF forms while maintaining document integrity and formatting.

  1. 1. Open Your PDF Form: Download and launch WPS Office, then open your interactive PDF document.
  2. 2. Access Form Tools: Navigate to the 'Form' tab on the top ribbon to access specialized form-filling and editing tools.
  3. 3. Edit and Format: Click directly into form fields to enter text, or switch to the 'Edit' tab to modify existing static PDF text and adjust formatting easily.
  4. 4. Save Your Document: Click 'Save' or 'Save As' to preserve your filled data, layouts, and applied rich-text styles securely.
Edit PDF text, images, and forms natively with an intuitive interfaceFully compatible with standard Adobe PDF form structures and Microsoft Office formatsLightweight architecture ensures fast loading and smooth performanceFree to use for everyday PDF reading, filling, and annotation tasks
microsoft office alternative - wps office

Frequently Asked Questions

Can I use both manual formatting and a calculation script in a PDF form?

No, the calculation script completely overwrites manually entered values and their standard formatting upon execution. You must handle all desired formatting within the calculation script itself.

How do I enable rich text in a PDF form field?

In the form field properties menu, navigate to the 'Options' tab and check the box for 'Allow Rich Text Formatting'. This setting tells the PDF viewer to accept rich-text inputs and JavaScript Span objects.

Why does my text formatting change only when I click out of the field?

Calculation scripts are typically triggered by an 'OnBlur' or similar exit event. This means the script executes and overwrites the field's value immediately after you exit (or click out of) the active field.

What is a Span object in PDF JavaScript?

A Span object is a JavaScript structure used within PDF forms to define specific text properties (such as font weight, color, style, and size) for a targeted segment of rich text within a form field.