Back to Articles List

How do I add a custom tool to the toolbar, using JavaScript, in the Editor?


I've written a JavaScript and would like to add it to the toolbar. How do I do this?


Firstly, it's worth noting that we generally don't write scripts for users, as it takes either support staff, or developers, away from helping other users. Exceptions may be made when scripts are extremely simple, but we don't guarantee it. It's also worth noting that we support most of the features and functions of the Adobe JavaScript API, which are documented in the Adobe JavaScript API Reference, including those found below. A working knowledge of JavaScript is assumed for this article. If you are not familiar with JavaScript, there are many resources available for free, online, that will help you learn.

The first step is to move all of the code so that it is contained within a function. For example, the following will set a specific zoom level:

function zoom175()
    this.zoom = 175;

Then you will need to use the app.addToolButton method to create the button. To continue with the above example, this would be as follows:

    cName: "Zoom 175%",
    cLabel: "175%",
    cExec: "zoom175()",
    cTooltext: "Zoom to 175%",
    cEnable: true,
    nPos: -1
Parameters of addToolButton:
**Note: A full description of how to use each of these parameters is well beyond the scope of this KB article. Please refer to the Adobe JavaScript API Reference for a more thorough walkthrough.
cName: Required – This is the identifier for the button and must be unique.
cLabel: Optional – Specifies text label to be displayed on the toolbar, next to the icon. If left blank, only the icon is used. If left blank and no icon is supplied, a stock icon is used and no label provided.
cExec: Required - This is where the function to be executed is entered.
cTooltext: Optional - The text entered here is used as the tool’s tooltip.
cEnable: Optional - Determines whether or not to enable button on the toolbar. Use true (default parameter) to enable or false to disable.
nPos: Determines the tool’s position on the toolbar. If -1 (default value) is entered, the tool is appended (added to the end of) the toolbar.
oIcon: Optional - Provides an icon for the toolbar button. An Icon Stream must be provided for this to work.


Now you will need to save the script under the JavaScripts folder under either the installation folder (e.g. default is C:\Program Files\Tracker Software\PDF Editor), or %appdata%\Roaming\Tracker Software\PDFXEditor\3.0. The folder is not created by default as the majority of users do not require custom JavaScripts, but it can easily be created by right clicking in Windows Explorer and selecting New --> Folder (Ctrl + Shift + N), but please be aware that the folder name is case sensitive and needs to be written as JavaScripts. When you next launch the Editor you should now see your new toolbar buttons.

Was this article helpful?
Yes No Somewhat