How to Open Another PDF Using Acrobat JavaScript and a Button
Question details
The user needs to create an interactive form button in a PDF that executes a JavaScript function to securely open a different PDF document.

- Product
- Adobe Acrobat
- Device & OS
- not provided
- Scenario
- Adding interactive navigation elements to PDF forms using JavaScript while complying with internal security restrictions.
- Observed behavior
- The user needs the correct syntax to define a document-level script using addScript (passing it as a string) and must configure folder-level trusted scripts to bypass app.openDoc security blocks.
Ensure both the source PDF and the target PDF are saved in accessible local directories, and verify that your PDF editor's JavaScript security settings allow script execution.
Configure Trusted Folder-Level JavaScript and Button Actions
Use a combination of folder-level trusted scripts and document-level configurations to safely execute the app.openDoc method from a form button.
Because opening external documents poses a security risk, modern PDF readers restrict the app.openDoc JavaScript method. To bypass this restriction for internal forms, you must create a trusted folder-level script and call it from your document-level button action.
Create a new .js file in your PDF application's local JavaScripts folder. Define a trusted function that encapsulates the app.openDoc method using app.trustedFunction so it is authorized to run.
If you are using the addScript method to dynamically attach the script, ensure that the second parameter (the actual function body) is passed strictly as a text string.
Open the target PDF document and set its 'disclosed' property to true. This ensures the source PDF's script is permitted to access and read the target file after it is opened.
Right-click your form button to open Properties, go to the Actions tab, select 'Mouse Up' as the trigger, and choose 'Run a JavaScript'. Enter the code to call your trusted document-level function and specify the exact file path to the target PDF.

Easily Link PDFs Together Using WPS Office
Skip the complex JavaScript coding and security configurations. WPS Office provides an intuitive PDF editor that lets you quickly insert interactive links and buttons to open other files natively with just a few clicks.
- 1. Open Your PDF in WPS: Launch WPS Office and open the primary PDF document where you want to add the navigation link or button.
- 2. Insert a Link: Navigate to the 'Edit' tab and click on the 'Link' tool. Draw a rectangular area where you want the clickable region or button to appear.
- 3. Configure the File Action: In the Link Properties dialog, select 'Open a File' as the triggered action. Browse your computer to select the target PDF document and click OK to save your changes.

Frequently Asked Questions
Why is my app.openDoc script not working in Acrobat?
Acrobat disables app.openDoc in document-level scripts by default for security reasons. You must wrap the command in a trusted function saved as a folder-level .js script on the local machine to execute it successfully.
What does the 'disclosed' method mean in Acrobat JavaScript?
Setting 'this.disclosed = true' in the target PDF allows other PDFs to access its Document Object Model (DOM) and execute secondary operations after it is opened via JavaScript.
How do I format the addScript parameter correctly?
When using the addScript method to inject JavaScript into a PDF form, the actual script code (the second parameter) must be formatted as a text string, usually wrapped in quotation marks, rather than passed as a raw function.




