How to Apply Strikethrough Formatting to Generated Acrobat Form Text
Question details
The user needs to dynamically apply strikethrough formatting to specific words in an Acrobat PDF form field populated via JavaScript.

- Product
- Adobe Acrobat
- Device & OS
- not provided
- Scenario
- A PDF form uses JavaScript to populate a text field automatically based on another field's input (e.g., containing 'Y'), and certain sections of the generated text require special formatting.
- Observed behavior
- The user wants to format specific generated text with a strikethrough line instead of outputting standard plain text strings.
Ensure you have access to the form editing tools in your PDF software and that your target text field is properly configured to accept rich text formatting.
Use JavaScript Rich Text Spans to Apply Strikethrough
Enable rich text formatting in the target field's properties, then use an array of rich-text spans within your JavaScript calculation script to selectively apply the strikethrough format.
Standard text assignment using event.value only supports plain text. To apply text styles like strikethrough to specific words in Adobe Acrobat, you must use the event.richValue property and define each section of text as an independent formatting span.
Right-click your target text field and select 'Properties'. Navigate to the 'Options' tab and check the box for 'Allow Rich Text Formatting'.
Go to the 'Calculate' tab in the field properties and select 'Custom calculation script'. Click 'Edit' to open the JavaScript editor.
Create an array of objects to act as spans. Assign plain text to the first span (e.g., spans[0].text = 'SPECIFIC '). Create a second span for the strikethrough text (e.g., spans[1].text = 'TEXT') and set spans[1].strikethrough = true.
Assign the completed array to the field's event.richValue (e.g., event.richValue = spans;). If the condition is not met, ensure you clear the field by setting event.value = '';

Edit and Format PDF Text Easily with WPS PDF
While custom JavaScript provides dynamic form filling, you can often achieve your document goals much faster using intuitive direct editing tools. WPS Office offers powerful PDF features to edit text, apply strikethroughs natively, and manage interactive forms without writing a single line of code.
- 1. Open Your PDF: Launch WPS Office and open your interactive PDF document or form.
- 2. Access Edit Mode: Navigate to the 'Edit' tab on the top ribbon and select 'Edit Text' to make the document's content selectable.
- 3. Apply Strikethrough Visually: Highlight the specific text you wish to strike out, then click the 'Strikethrough' icon in the floating formatting toolbar.
- 4. Save Your Form: Click 'Save' to ensure your newly formatted text is permanently applied to the PDF file.

Frequently Asked Questions
Why isn't my JavaScript strikethrough formatting showing up in the PDF form?
If your script executes but the text remains unformatted, verify that 'Allow Rich Text Formatting' is enabled in the field's Properties under the Options tab. Without this setting checked, event.richValue scripts will be ignored.
Can I apply bold or italic formatting using the same rich text span method?
Yes. Within your JavaScript span array, you can define bold text by adding spans[x].fontWeight = 800, or apply italics by using spans[x].fontStyle = 'italic' alongside the text property.
Does the standard event.value property support any text formatting?
No, event.value only outputs plain string text. To display formatted text variations (such as strikethroughs, different colors, or fonts) dynamically within the same field, you must rely on the event.richValue property.




