How to Show PDF Form Fields Only in Adobe Reader Using JavaScript
Question details
The user needs specific PDF form fields to remain hidden in Acrobat but become visible when opened in Adobe Reader, potentially triggered by a button.

- Product
- Adobe Acrobat / Adobe Reader
- Device & OS
- not provided
- Scenario
- Developing a dynamic PDF form that conditionally shows fields based on the viewer software used by the end user.
- Observed behavior
- Required fields and hidden radio buttons need a mechanism to dynamically update their display state, as they currently appear incorrectly or unexpectedly across different viewer environments.
Ensure you have access to the JavaScript editor in your PDF authoring software and keep a backup of your original PDF form before running scripts.
Use Document JavaScript to Detect Viewer Type
Apply a JavaScript snippet to check if the application is Adobe Reader and change field display settings accordingly.
You can use the `app.viewerType` property in Acrobat JavaScript to differentiate between Acrobat (the editor) and Reader (the free viewer). By looping through an array of specified field names, you can dynamically set their visibility properties.
Open your PDF document in Adobe Acrobat, go to the Tools menu, and select 'Prepare Form'.
Navigate to the JavaScript settings by clicking the 'More' (gear) icon in the right-hand pane and choosing 'Document JavaScripts', or assign a 'Run a JavaScript' action to a specific 'Show' button.
Input the code to define your fields: `var fieldsToShow = ["Field1", "Field2", "Field3"];` replacing the placeholder names with your actual field names.
Paste the following loop to check the viewer type: `for (var i in fieldsToShow) { var f = this.getField(fieldsToShow[i]); if (f) f.display = (app.viewerType == "Reader") ? display.visible : display.hidden; }`.
Save your PDF document and open it in both Adobe Acrobat and Adobe Reader to verify that the fields toggle visibility correctly based on the application.

Create and Edit PDF Forms Easily with WPS Office
While advanced JavaScript like app.viewerType is tailored to specific programs, WPS Office offers a streamlined, user-friendly interface for creating, filling, and managing PDF forms natively without writing complex code.
- 1. Open your PDF: Launch WPS Office and open your PDF document.
- 2. Navigate to the Form Tab: Click on the 'Form' tab located on the top ribbon to access all form editing tools.
- 3. Insert Interactive Fields: Use the toolbar to click and drag text fields, checkboxes, or buttons directly onto your document.
- 4. Modify Field Properties: Right-click any form field to adjust its properties, such as making it required or hidden.
- 5. Save and Export: Save your completed or edited form directly to your device for easy sharing.

Frequently Asked Questions
Why do my hidden PDF form fields still show up in some programs?
This usually happens if the PDF viewer being used does not fully support Acrobat JavaScript or if the script has syntax errors preventing the `display.hidden` property from triggering. Non-Adobe readers may ignore `app.viewerType` entirely.
Can I use this JavaScript to hide radio buttons?
Yes, but radio buttons can sometimes behave unexpectedly depending on how their groups are configured. Ensure you are targeting the exact name of the radio button group in your JavaScript array, not just the individual button.
How do I find the correct field names to include in my JavaScript array?
In form editing mode, right-click the specific field, select Properties, and look at the 'Name' attribute under the General tab. Copy this exact name into your `fieldsToShow` array.




