Knowledgebase

Search or Ask a Question

This is a keyword search that looks for matching articles that contain one or more words specified by a user in articles’ tags, title and content. The search results are sorted by the frequency of words found in articles and weighted to give preference to tags, title and article content in that order. Words from the article tags rate higher than words from the article title and words from the article title rate higher than words from the article content. The logical operators e.g. + ! || && etc or quotes to search for a phrase are disregarded.

I have a problem with add a custom tool to the toolbar, using JavaScript, in the Editor?

  • Knowledge Base Article: KB510
  • Created On: May 12, 2017 10:43 AM
  • Last Modified: : May 13, 2017 02:27 AM
  • 122 visit(s)
  • Back to Articles List
Question

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

 

 

Answer

 

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:
 
app.addToolButton({
    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.
 

Vote

Was this article helpful?

Yes No Somewhat