How to Format Multiline and Bold Placeholder Text in PDF Forms
Question details
The user needs to display placeholder text on multiple lines with specific words in bold within a PDF form field.

- Product
- PDF Forms
- Device & OS
- not provided
- Scenario
- Using custom JavaScript to create a form field that dynamically displays formatted placeholder text.
- Observed behavior
- Standard text fields apply uniform formatting, so the user seeks the correct JavaScript syntax and field settings to achieve multiline and partial bold formatting.
Ensure you are using a PDF editor that supports JavaScript execution and advanced form field properties. You will need access to the field's properties dialog to enable rich text features.
Enable Rich-Text Formatting and Apply JavaScript Spans
Enable rich text in the form field properties and use the event.richValue property in JavaScript to define multiple formatting spans.
To display varying text styles (like bold and normal) within a single PDF form field, the field must be configured to accept rich text. Once enabled, you can use a JavaScript array of span objects to define the formatting for different text segments.
Right-click the target text field and open its 'Properties'. Go to the 'Options' tab, then check both the 'Multi-line' and 'Allow Rich Text Formatting' checkboxes.
Switch to the 'Format' tab in the Properties window. Select 'Custom' from the format category list, and click the 'Edit' button to open the JavaScript editor.
Write your custom script using the event.richValue property. Assign an array of span objects, separating normal text and bold text (e.g., adding fontWeight: 800 to the bold span). Use the \n character in the text strings to force line breaks where needed.
Create and Edit PDF Forms Easily with WPS Office
WPS Office provides a comprehensive PDF editor that allows you to easily insert, edit, and format form fields without writing complex JavaScript code manually. Enjoy a lightweight and user-friendly interface for all your PDF needs.
- 1. Open PDF in WPS: Launch WPS Office and open your PDF document.
- 2. Access Form Tools: Navigate to the 'Form' tab to access various form controls like Text Fields, Check Boxes, and Dropdown menus.
- 3. Edit Field Properties: Double-click the inserted text field to open its properties, where you can easily adjust text appearance, multi-line settings, and formatting without advanced coding.

Frequently Asked Questions
Why is my multiline text not showing in the PDF form field?
Ensure that the 'Multi-line' option is checked in the text field's properties under the 'Options' tab. Without this, text will not wrap or recognize line breaks.
Can I make only part of the text bold in a standard PDF text field?
By default, standard text fields apply one style to all text. To format specific words, you must enable 'Allow Rich Text Formatting' in the field properties and apply formatting spans.
What is event.richValue in PDF JavaScript?
It is a JavaScript property used to assign rich text formatting, such as bolding, italics, or varying font colors, to specific segments (spans) of text within a field.




