JavaScripts in Acrobat can either be attached to a document – for example to validate a form field – or they can be loaded directly into the application as a folder level script. It’s pretty straight forward to figure out where to put a script that should run when a button is pressed in a form, but where do you install folder level scripts?
In my blog posts, I usually just list one of the paths that you would use for Acrobat running on Windows (e.g. in Splitting PDF Pages). This means that the Mac users are usually left out – which is a bit strange because I am a Mac user. Most Acrobat users are running it on Windows, so that’s why I can take that shortcut without upsetting too many people.
But where would you store these folder level scripts on a Mac – or on Windows if you just want them to be available for one user?
There is an app for that!
Acrobat provides a JavaScript function that returns configuration paths: app.getPath()
The JavaScript for Acrobat API Reference provides information about the getPath function. From that document we learn that there are two different kinds of paths: application level and user level. An application level path would be for all users on a certain computer, whereas a user level path is for one specific user. We can also see that Acrobat can report a number of different paths: root, eBooks, preferences, sequences, documents, javascript, stamps, dictionaries, plugIns, spPlugIns, help, temp, messages, resource and update.
So, to report the application level JavaScript path, we would run the following command in the JavaScript console (and if you want to run this on an Apple laptop, you need the information at “Developing Acrobat JavaScript on a MacBook” to execute a script in the console):
app.getPath("app", "javascript");
And, that command running in Acrobat 9 on a Mac would produce the follwing output:
/Macintosh HD/Applications/Adobe Acrobat 9 Pro/Adobe Acrobat Pro.app/Contents/MacOS/JavaScripts/
So, with this little script, you can find out where to save your JavaScripts regardless of what system you are using – and, you can also find out about other configuration paths in Acrobat.
OK, so it’s not really an app, but it’s easier to use than some apps I’ve seen.
At least this page is not just a copy of Adobe documentation, however, my goal when finding your site is to open a dialog File | Open which will allow me to select from a variety of scripts. All scripts I am writing need to be application level js files. I’m a newbie to Apple script so don’t beat me up too bad. BTW It is really irritating to find that many of the snippets dispayed in the countless blogs require a predefined document on which to act.
Pingback: Extract PDF Pages Based on Content - KHKonsulting LLC
I agree with John
Isn’t there an easy edit to change the size and color of an existing stamp?
Tonia, the size can be changed by grabbing one of the resize handles after you place the stamp, and then drag it to it’s desired size. The color cannot be changed without actually changing the stamp.
Karl i have a question about adding a pick list to a dynamic stamp. I have a stamp that asks the user for the some information and I would like to have one of the things be a dropdown list that the user picks the reason from a list.
I am using the below code to how would you make the reason field a dropdown list
if ((event.source.forReal)&&(event.source.stampName == “#Invalid_Stamp”))
{
this.getField(“Reason”).value = app.response(“Reason:”);
this.getField(“Analyst”).value = app.response(“Analyst:”);
this.getField(“Date”).value = util.printd(“mm/dd/yyyy” , new Date());
}
Any help would be appreciated.
Ray
Ray, for a dynamic stamp, you would have to create a dialog window where the user selects the items that should go on the stamp, and then the stamp’s form fields are filled out by the stamp script. This requires some serious programming. I would recommend that you take a look at Thom Parker’s book about stamps (or his tutorials on the pdfscripting.com site).