Other PDF Issues

How to Show a Custom JavaScript Dialog Once for Multiple PDF Files in Adobe Acrobat

Nimra MalikNimra Malik Nov 5, 2026 869 views

Question details

The user needs a custom JavaScript dialog in Adobe Acrobat Pro's Action Wizard to appear only once, reusing the user's input for all files in a batch process instead of prompting per file.

How to Show a Custom JavaScript Dialog Once for Multiple PDF Files in Adobe Acrobat
Product
Adobe Acrobat Pro
Device & OS
not provided
Scenario
Running a batch script using the Action Wizard on multiple PDF documents.
Observed behavior
The Action Wizard script prompts the user with the custom dialog for every single file in the batch, rather than asking once and applying the settings globally.
Before you start

Ensure you have Adobe Acrobat Pro installed with access to the Action Wizard, and possess basic familiarity with modifying JavaScript code for Acrobat.

Solution 1Recommended

Use a Global Variable to Store Dialog Settings

By assigning your custom dialog inputs to a global variable, you can instruct the script to bypass the prompt for subsequent files in the batch execution.

In Adobe Acrobat Pro, the Action Wizard executes the assigned JavaScript independently for each document. To share data across these separate script executions, you must use the `global` object. By checking if a specific global variable exists, you can prompt the user once and then reuse their inputs for the rest of the batch.

1
Define the variable check

At the beginning of your Action Wizard script, add a condition like `if (global.myWatermarkData == null)` to check if the settings have already been captured in a previous iteration.

2
Prompt and save user input

Inside the condition, add the code to display your custom dialog and save the returned values directly to the global variable (e.g., `global.myWatermarkData = dialogResult;`).

3
Apply the settings

Outside of the condition, write the execution logic that applies the values stored in the global variable to the current PDF document.

4
Clear the global variable

To prevent the settings from being accidentally applied to a future batch, manually delete the global variable using `delete global.myWatermarkData;` at the very end of your batch process logic, or be prepared to restart Acrobat.

Use a Global Variable to Store Dialog Settings
Remember to Clear the Variable: If you do not delete the global variable after the batch finishes, the stored data will automatically be used the next time you run the action during the same Acrobat session without prompting you again.
Native PDF Batch Processing

Batch Process PDFs Easily with WPS Office

Instead of writing complex JavaScript to manage custom dialogs and global variables, you can use WPS Office's built-in PDF tools to batch process multiple documents—such as adding watermarks—in just a few clicks.

  1. 1. Open WPS PDF: Launch WPS Office on your computer and open the WPS PDF application.
  2. 2. Access Batch Tools: Navigate to the 'Tools' or 'Batch' tab and select the 'Batch Add Watermark' feature (or whichever batch tool you need).
  3. 3. Add Your PDF Files: Click 'Add Files' or simply drag and drop all the PDF documents you want to process into the batch list.
  4. 4. Configure Settings Once: Set up your custom watermark text, image, and positioning within the unified settings dialog box.
  5. 5. Run the Batch: Click the 'Start' button to automatically apply your single configuration across all selected PDF files.
No JavaScript or coding required to process filesBuilt-in batch PDF watermarking and document editingHighly compatible with all standard PDF formats used by Microsoft Office and AdobeLightweight application with a highly intuitive user interface
microsoft office alternative - wps office

Frequently Asked Questions

Why does the Action Wizard run the script for every single file?

The Action Wizard treats each document in a batch process as an independent execution environment. It automatically re-runs the entire script for every file, which is why standard local variables and dialogs reset and reappear each time unless stored globally.

How do I define a global variable in Acrobat JavaScript?

You define a global variable by prefixing your variable name with the `global` object, such as `global.mySettings = value;`. This allows the data to persist in the application's memory across different document script executions.

What happens if I forget to delete the global variable?

If the global variable is not explicitly deleted at the end of the script execution, it will remain in Acrobat's memory. The next time you run the Action Wizard, it will bypass the dialog entirely and apply the outdated settings from your previous session. Restarting the Acrobat application will completely clear the variable.

Can I use this JavaScript global variable method for tasks other than watermarking?

Yes, you can use global variables to store user input for any batch processing task in Adobe Acrobat, such as setting custom document metadata, applying specific security permissions, or defining automated page extraction parameters.