How to Make PDF Form Field Fill Colors Invisible When Printing
Question details
The user wants to display a background fill color for text fields in a PDF on screen, but ensure that the color does not appear when the document is printed.

- Product
- Device & OS
- not provided
- Scenario
- Preparing a PDF form for both digital filling and clean physical printing, where colored fields aid digital visibility but waste ink or obscure text on paper.
- Observed behavior
- By default, PDF form fields print with their on-screen fill color intact. The goal is to print the user-entered text without the background color while retaining the color on screen.
Ensure you are using a PDF editor that supports adding document-level JavaScript and accessing print-related action triggers.
Use Document-Level JavaScript for Print Events
By attaching a script to the document's "Will Print" and "Did Print" events, you can automatically remove the field colors right before printing and restore them immediately afterward.
This method requires adding standard PDF JavaScript. It ensures that the background color is temporarily set to transparent when the print dialog is invoked, and then reverted to its original color once the printing task is sent to the spooler.
Navigate to your PDF editor's Document Properties or JavaScript settings to access document-level actions.
Select the 'Will Print' event trigger and add a script to set the fill color of your form fields to transparent. For example: `this.getField("YourFieldName").fillColor = color.transparent;`
Select the 'Did Print' event trigger and add a script to restore the fill color of your form fields to your preferred color. For example: `this.getField("YourFieldName").fillColor = color.gray;`
Save the PDF document. Open the print preview to ensure the background color is successfully removed during the printing process.

Create a Custom Print Button with Embedded JavaScript
If you cannot edit document-level print events directly, you can add a dedicated Print button to the form that executes the color toggle and print command sequentially.
Use WPS Office to Edit PDF Forms and Properties
WPS Office provides robust PDF editing tools, allowing you to design interactive forms, edit field properties, and manage document settings effortlessly.
- 1. Open the PDF: Launch WPS Office and open your PDF form.
- 2. Access Form Tools: Navigate to the Form tab on the top ribbon to access form field editing capabilities.
- 3. Edit Properties: Right-click the specific form field and select Properties to adjust Appearance and action settings.
- 4. Save and Print: Save your modified document and use the standard Print dialog to output your file.

Frequently Asked Questions
Why does the 'Visible but doesn't print' property not work for this issue?
Setting a form field's property to 'Visible but doesn't print' hides the entire field during printing. This means not only the background color is hidden, but the text the user entered is also omitted. JavaScript is required to hide just the background while keeping the text.
What color codes should I use in my PDF JavaScript?
Standard PDF JavaScript supports predefined color objects. You can use colors like `color.transparent`, `color.white`, `color.black`, or define specific RGB arrays such as `["RGB", 1, 0, 0]` for red.
Will the JavaScript work on all PDF readers?
Most standard desktop PDF editors and readers support document-level JavaScript. However, some basic browser-based PDF viewers or mobile applications may restrict or ignore these scripts for security reasons.
Can I remove the fill color manually before printing without scripts?
Yes. If you don't want to use JavaScript, you can manually open the form editing tools, change the field fill colors to transparent, print the document, and then close the file without saving to keep the original formatting intact.




