Tutorials, tools, scripts and samples for scripting Acrobat and PDFpdfscripting.com
HomeVideo TutorialsCopy-n-Paste ScriptsDownload LibraryFree ContentSearchMEMBERS AREA
Home | Instructions for Installing Folder L . . .

Instructions for Installing Folder Level Scripts (Automation Tools)

Printer-Friendly Format

Acrobat automation tools built with JavaScript are typically saved in a JavaScript (".js") file. To be used in Acrobat a JavaScript file must be placed in one of the two Acrobat/Reader JavaScript folders. Hence, the scripts in a JavaScript file are referred to as Folder Level Scripts. A JavaScript file must be placed in only one of the two folders. Placing the same file in both folders may cause very bad things to happen because the code in one place will overwrite the code in another place. Execute each line of the following code in the Acrobat JavaScript Console (Ctrl+J on Windows, Command+J on Mac) to find the location of the JavaScript folders on your system:



On Windows, the application JavaScript folder is usually located at:
C:\Program Files\Adobe\Acrobat 8.0\Acrobat\JavaScripts

On Mac, the application JavaScript folder is in the configuration file inside the Acrobat Application Package.

Scripts in "app" folder are visible to all users on the same system, whereas the "user" folder is only visible to a particular user on the system. The local "user" folder is located in the local user area of the file system. This location varies quite a bit between platforms and operating systems. For example, in Acrobat 10.1.1 Adobe changed the location of the "local" JavaScript folder for security reasons. Anyone who already had custom JavaScript files in the user area had a rude awakening when they did the 10.1.1 update and all of their JavaScript tools disappeared. While this was quite a shock, the solution is very simple. Run the code above to find the new location, and then copy the script files into it.

If Acrobat and Reader are installed on the same system then they will share the same local "user" folder, but each will have its own "app" folder. So, all applications (Acrobat and Reader) share the same "user" folder and all users share the same "application" folder. As such, do not place any tools into the "user" folder that cannot be used by Reader, i.e., tools that perform operations not allowed by Reader (The Acrobat JavaScript Reference indicates which functions and properties are restricted in Reader).

Acrobat/Reader loads and runs the JavaScript files on start up, and only on start up. The main purpose of all folder level scripts is to setup data and functions that will be used later, by other scripts. When the folder level scripts are run at start up, they run in a privileged context. This is important because many of the functions defined in a folder level script will need to be created as trusted functions. A Folder level script is the only practical way to create trusted functions. Trusted functions are necessary if any of the operations the function performs is privileged. Once defined, a folder level function can be called from any script in Acrobat: a stamp, an Action, a form, or another folder level function.

Many automation scripts will create a toolbar button or menu item. These toolbar buttons and menu items look exactly like any other toolbar button or menu item in Acrobat. These are the main entry points for automation scripts. In Acrobat/Reader 9 and earlier, JavaScript toolbar buttons are placed on the "Add-Ons" toolbar (Figure 1). If this toolbar is not visible then Right Click on an empty part of the Acrobat toolbar area and select "Add-Ons." In Acrobat/Reader X, JavaScript toolbar buttons are placed in the "Plug-In Add-on Tools" Pane in the Tools Panel (Figure 2).

JavaScript toolbar buttons were added to Acrobat/Reader in version 6. However, most of the automation scripts that can be downloaded from this site are intended to be used with Acrobat 7 or later. There are some differences in the DOM function that adds toolbar buttons, app.addToolButton().

Some scripts may contain functionality that prevents it from being used in Adobe Reader, on a Mac, or in a particular version of Acrobat. When writing, or using, a folder level automation script always be aware of the environment, and the version and variation of Acrobat the script is intended to be used with.

<b>Figure 1</b> - JavaScript Toolbar Button location for Acrobat versions 6 to 9.
Figure 1 - JavaScript Toolbar Button location for Acrobat versions 6 to 9.

<b>Figure 2</b> - JavaScript Toolbar Button location for Acrobat version X.
Figure 2 - JavaScript Toolbar Button location for Acrobat version X.

·  Creating Acrobat Toolbar Buttons
·  Beginning Acrobat JavaScript: Introduction to Scripting in Acrobat