Turn Acrobat JavaScript Console Code Into a Reusable Tool
Question details
Turn JavaScript tested in Acrobat's Console into a reusable tool that can run on compatible PDFs.

- Product
- Adobe Acrobat
- Device & OS
- not provided
- Scenario
- The user has working Acrobat JavaScript Console code and wants to run it repeatedly without pasting it into the Console.
- Observed behavior
- The desired result is a reusable command or action that runs the code on a compatible PDF.
Test the code on a compatible PDF in Acrobat's JavaScript Console and check whether it requires privileged operations. Make sure Acrobat JavaScript is enabled in Preferences and identify any code that depends on the Console or a specific document.
Install a folder-level script and add a toolbar button
Use this method to make the script available as a reusable Acrobat command.
Folder-level scripts load when Acrobat starts. Put the code in a named function and adapt any Console-specific document references so the function operates on the intended open PDF.
If the code performs privileged operations, those operations may need a folder-level trusted function using app.trustedFunction and an appropriate app.beginPriv/app.endPriv block. A trusted function does not bypass every security restriction.
Open Acrobat's JavaScript Console and run console.println(app.getPath("user", "javascript")); to locate the user JavaScripts folder. Create the folder if it does not already exist.
In a text editor, save your tested code as a .js file in that folder. Wrap the reusable code in a named function, such as myReusableTool(), and make sure it selects or receives the intended open PDF.
Add a folder-level call such as app.addToolButton({cName: "MyReusableTool", cLabel: "My Tool", cExec: "myReusableTool();"}); to the same .js file. Use a unique cName and ensure cExec calls your function.
Close and reopen Acrobat, open a compatible PDF, and look for the custom button in the available toolbar controls. Run it and check the JavaScript Console for errors if it does not appear or execute.

Create an Acrobat Action Wizard action
Use an action when you want to run JavaScript as part of a repeatable workflow on selected PDF files.
Work with PDFs and Office files in WPS Office
WPS Office is a free, lightweight alternative for viewing and editing everyday documents in a familiar interface. Its Office format compatibility helps you move existing files into your workflow, although it does not install or run Acrobat folder-level JavaScript tools.

Frequently Asked Questions
Why does my Acrobat toolbar button not appear?
Check that the .js file is in the user JavaScripts folder, JavaScript is enabled in Preferences, and Acrobat was restarted after installation. Open the JavaScript Console to check for errors in the folder-level script.
Can I add the script to a menu instead of a toolbar?
Yes. A folder-level script can use app.addMenuItem to register a custom menu command that calls your function. Restart Acrobat after saving the script and check the relevant menu.
When do I need a trusted function?
Some privileged Acrobat JavaScript operations require a trusted context. Define an app.trustedFunction in a folder-level script and use app.beginPriv and app.endPriv around permitted privileged operations; other security restrictions may still apply.
Can Action Wizard run my script on multiple PDFs?
In Acrobat Pro, create an action with an Execute JavaScript step, save it, and select the files when you run the action. Test first to ensure the code works with each PDF and its permissions.




