How to Hide PDF Form Fields When Emailing or Printing
Question details
The user needs to hide unselected or empty dropdown fields when emailing a completed PDF form, applying the same visibility rules that successfully hide them during printing.

- Product
- Device & OS
- not provided
- Scenario
- Distributing a filled-out PDF form via email without showing empty form fields.
- Observed behavior
- Unselected dropdown fields are correctly hidden when the document is printed, but they remain fully visible when the same PDF is attached to an email.
Ensure you have a PDF editor that supports advanced form creation and JavaScript, and save a backup copy of your original PDF form before modifying its code or structure.
Use a Custom Form Button with JavaScript
Standard email attachment actions bypass print-specific scripts. To apply visibility rules before emailing, you must create a dedicated 'Submit' or 'Email' button within the PDF that triggers a JavaScript visibility script before sending.
Because printing and emailing rely on different underlying actions, a script triggered by a 'Print' event will not execute when a user simply attaches the PDF to an email. Creating an interactive button inside the document forces the visibility script to run before packaging the file into an email message.
Open your PDF in form editing mode and insert a 'Button' field from the form controls menu onto your document.
Right-click the new button and select 'Properties'. In the 'General' or 'Options' tab, label the button appropriately (e.g., 'Submit via Email').
Navigate to the 'Actions' tab within the properties window. Set the trigger to 'Mouse Up' and choose 'Run a JavaScript' as the action type.
Write or paste a JavaScript snippet that loops through your form fields, hides the unselected dropdowns, and then calls a method like `app.mailMsg()` or `doc.mailDoc()` to initiate the email draft with the updated document.

Adjust Built-in Field Visibility Settings for Printing
If you only need to ensure fields do not appear when the document is printed, you can manage this without JavaScript using standard form field properties.
Create and Manage Interactive PDF Forms with WPS Office
WPS Office provides a comprehensive suite of PDF tools, allowing you to easily create, edit, and manage interactive forms with text fields, dropdowns, and custom buttons to optimize document sharing.
- 1. Open the PDF Form: Launch WPS Office and open your PDF document within the PDF editor.
- 2. Access Form Tools: Select the 'Form' tab from the top toolbar to reveal the interactive form controls.
- 3. Insert Interactive Elements: Click to insert push buttons, dropdown menus, or text fields directly onto your document.
- 4. Modify Field Properties: Double-click any form element to access its properties, where you can adjust visibility settings, labels, and default values.

Frequently Asked Questions
Why do hidden fields show up when I attach the PDF to an email?
Standard email attachment actions performed outside the PDF do not execute the PDF's internal formatting or printing scripts. To hide fields before emailing, you must trigger the email from within the PDF using a custom button and JavaScript.
Can I hide specific PDF form fields only during printing?
Yes. In the field properties under the 'General' tab, you can set the visibility property to 'Visible but doesn't print'. This requires no coding and ensures the field is hidden on paper.
Do I need programming knowledge to create interactive PDF forms?
Basic forms do not require coding. You can set simple visibility rules directly in the field properties using most PDF editors. However, complex actions like conditional hiding immediately prior to emailing do require basic JavaScript knowledge.




