How to Deploy an Acrobat JavaScript Menu or Context-Menu Action in PDFs
Question details
A developer wants to deploy a JavaScript action to add a custom menu item or context-menu option for users of a PDF application.

- Product
- Adobe Acrobat / PDF
- Device & OS
- not provided
- Scenario
- Attempting to create and deploy a custom JavaScript interface, such as a right-click context menu or toolbar option, to enhance the PDF user experience.
- Observed behavior
- Confusion regarding deployment methods, as PDF scripts function within the sandbox of the PDF reader and cannot typically modify system-level menus like standalone applications.
Determine whether your JavaScript needs to run globally for the application (affecting all PDFs) or only when a specific PDF document is opened.
Use Folder-Level Scripts for Application Menus
Deploy folder-level JavaScript files to add persistent custom menu items or toolbar buttons to the PDF application.
Acrobat JavaScript cannot be deployed like a standard executable application. To add items to the application's menu or toolbars, the script must be placed in a specific local directory on the user's computer.
Document-level scripts embedded inside a PDF file cannot create application-level menus due to strict security sandboxing.
Locate the JavaScripts folder for your PDF application. In Adobe Acrobat, this is typically found in the installation directory under 'Acrobat\Javascripts' or in the user's AppData directory.
Write your script using the 'app.addMenuItem' or 'app.addToolButton' methods and save it as a standard .js file.
Distribute this .js file to your users and instruct them to copy it into their respective local JavaScripts folder.
Have the user restart the PDF application. The script will initialize on startup and render the new menu items.

Try WPS Office for Lightweight, Script-Free PDF Editing
While Adobe Acrobat supports advanced folder-level JavaScripting for custom menus, setting it up across multiple users can be complex and poses security restrictions. If you or your users simply need a fast, reliable, and user-friendly way to edit, read, and manage PDFs, WPS Office is an excellent free alternative.
- 1. Download WPS Office: Visit the official WPS website to download and install the free suite.
- 2. Open your PDF: Launch WPS PDF and open your document directly to access all built-in reading and editing tools.
- 3. Edit without coding: Utilize the comprehensive UI ribbons to manipulate text, fill forms, and annotate without needing custom JavaScript menus.

Frequently Asked Questions
Can I embed a script in a PDF to permanently change the user's application menu?
No. Scripts embedded inside a specific PDF document generally cannot alter the PDF reader's application-level menus or toolbars permanently due to security restrictions. Application changes require folder-level scripts installed locally.
Why isn't my custom JavaScript context menu appearing in Windows?
PDF applications restrict JavaScript from interacting with operating system features. If you are trying to add a right-click option to the Windows or Mac OS system desktop context menu, Acrobat JavaScript cannot natively achieve this.
What is the difference between document-level and folder-level JavaScript?
Document-level scripts are embedded within a single PDF and only execute when that specific file is open. Folder-level scripts are saved in the application's installation directory and execute every time the PDF software is launched, allowing them to add persistent toolbars or app menus.




