PDF Security & Access Issues

How to Open Another PDF Using Acrobat JavaScript and a Button

Khadija KhanKhadija Khan Nov 5, 2026 870 views

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.

How to Open Another PDF Using Acrobat JavaScript and a Button
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.
Before you start

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.

Solution 1Recommended

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.

1
Create a Folder-Level Trusted Function

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.

2
Define the Document-Level Script

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.

3
Configure the Target PDF Disclosed Method

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.

4
Set the Button MouseUp Action

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.

Configure Trusted Folder-Level JavaScript and Button Actions
Local Distribution Notice: Folder-level scripts affect the behavior of the PDF viewer locally. This means the script cannot be distributed simply by sending the PDF file to another user; each user must have the folder-level script installed on their machine.
Advanced PDF Editor

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. 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. 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. 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.
No JavaScript coding required for basic cross-document file navigationFully compatible with standard PDF interactive elements and Microsoft Office formatsLightweight, fast, and completely free to download for everyday editing tasks
microsoft office alternative - wps office

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.