do JavaScript doesn't work on Leopard

I’m running Acrobat 8 on Tiger and I need to extract pages from batch of PDFs.

Since AppleScript doesn’t have a command for this, I thought of using do JavaScript from AS:

tell application "Adobe Acrobat 8.0 Professional"
	do JavaScript "this.extractPages(0,1);"
end tell

but it prompts me “Syntax Error: Expected end of line, etc. but found identifier.

But it works fine if I use “do script” instead of “do JavaScript”:

tell application "Adobe Acrobat 8.0 Professional"
	do script "this.extractPages(0,1);"
end tell

I would like to understand the reason behind, please advise!

However, the above scripts don’t work on Leopard. It prompts that it doesn’t understand the command. Please advise!


I don’t have Acrobat 8 anymore, but in 9 the scripting dictionary says:

do script‚v : Perform a JavaScript.
do script [text] : The actual text of the JavaScript to perform.
[file alias] : The file containing the JavaScript to perform.

I don’t see a command for do javascript

I don’t know why it wouldn’t work in Leopard. Any differences on your Leopard machine? Did you run it on the same document so you know it’s not the document that caused the error?

Thank you, Matt-Boy.

I have done several tests, using Acrobat 7 through 9 on Tiger, Leopard and Snow Leopard. Found Tiger works fine but not Leopard and Snow Leopard, regardless of which version of Acrobat used.

The result returned is:

Any advice on how to overcome this OS dependent issue?

FWIW, I just ran your script fine with Acrobat Pro X under 10.6.6.

Thank you, Shane Stanley.

I don’t have Acrobat Pro X yet, would appreciate it if you could help using version 9 to try?


You will find numerous posts here about using javascript being broken in Acrobat on the Leopard OS. Many suspect Applescript’s change to Unicode text. It would look like from Shane’s comments with X that this has been addressed. I don’t have 9 or X so I can’t really comment further.

Yes, it also works here with v9. I see a comment in a script here that uses js to to add annotations: “not working with Acrobat 8 under OS 10.5, but works with Acrobat 9 in OS 10.5 and 10.6”

Sorry, I have overlook those posts. Thank you for your reminder, Mark67!

I did try on 10.6 with v9, it still prompts me the same message. Anyway, Thanks for your help, Shane Stanley!

Have you tried playing with the javascript preferences?

I don’t have any knowledge on this, could you please advise? Thanks!

In your application preferences you will have a tab on ‘JavaScript’ in that you can enable JavaScript and a few other related options. Make sure you have this set to on.

Thank you, will play with it later.