Scripting Acrobat Reader 9 not working

I have gone into Script Editor and opened up the library for Acrobat Reader 9. It gives me a bunch of commands and classes that sound useful… but I cant even get the most simplest thing to work. I try the following:


set myFile to choose file
tell application "Adobe Reader"
	set myDocuemnt to open myFile
	close myDocument
end tell

I get the error “The variable myDocument is not defined.” Acrobat does not appear to let me allocate the document to a variable.

suggestions

Hi,

maybe
myDocuemnt vs. myDocument
:wink:

Thanks for your post.

This seems extremely stupid on Adobe’s behalf as I am given the option to open the document in invisible mode which is good for speeding up processes… however if I do what you say and allocate the frontmost document, it takes the front most visible document.

Also another solution would have been to take the “document 1” (the newly loaded document) as the myDocument variable… however Acrobat does not follow the standard convention of putting new items in the list to the front. So if I already have PDF files open it will allocate one of them to the variable.

Has anybody else found Acrobat very crappy regarding its script ability?

I encounter very similar difficulties with Adobe Reader 9.1.3. E.g. the following simple scripts attempting to inquire about currently open pdf’s does not work and I found no variant in which it would work. I know these scripts are not very robust in case there would be no window open (only for purposes of this discussion made this simple). Therefore, I have of course made sure the state of Adobe Reader was in all test cases fine, i.e. Adobe Reader was running and had at least one pdf file open.

	tell application "Adobe Reader"
		activate
		set theNumOfOpenPDFs to (count documents)
		display dialog (theNumOfOpenPDFs as string)
        end tell

Above fails with “every document doesn’t understand the count message”. Or a little script such as

	tell application "Adobe Reader"
		activate
		set theFirstW to first window
		display dialog (name of theFirstW)
        end tell

fails with “Can’t get window 1”. Or

	tell application "Adobe Reader"
		activate
		set theTopPDFName to (get name of active doc)
        end tell

fails with “Can’t get name of active doc”. All scripts can be compiled, conform with the dictionary (AFAIK), yet all fail at runtime for reasons that escape me. All quite annoying. I guess there is no decent way by which one could AppleScript Adobe’s Reader, or does anyone know of one?

I’m afraid I know no solution. It simply appears that Adobe Reader is basically not scriptable. Nothing works! :frowning:

I find this pretty strange, given the fact that the dictionary seems to be made professionally. Does really no one know anything about what’s wrong with Applescriptability of Adobe Reader? Adobe?

I guess I found an answer at Adobe’s site for developers, i.e. file

http://www.adobe.com/devnet/acrobat/pdfs/reader_overview.pdf

states on page 25

On Mac OS, you may use Apple events and AppleScript. Adobe Reader supports only the following required Apple events:
●open
●print
●quit
●run

This all means that the confusing AppleScript dictionary Adobe Reader features is very misleading and is in fact all false. I do not know what Adobe has been doing, but it looks like this is far from being ok. IMHO Adobe Reader should either have a correct dictionary really stating how limited its AppleScript capabilities are or then state in a prominent place in the dictionary that it is valid only for Adobe Acrobat Pro.

However, I know for sure that Adobe Reader understands some more as above commands, at least also
●activate

But then that’s about all I fear.

your mentioned commands (except the print command) are basic AppleScript commands, which can be sent to any application even it’s not scriptable

So Adobe Reader has actually nil scripting capability built in, right? Adobe claims that Adobe Reader would be scriptable actually means only that Adobe relies on the core system services provided by OS X, isn’t it?

May this be as it may be, what I still find quite confusing is that Adobe Reader contains a full fledged AppleScript dictionary.

I don’t know, I use only Acrobat Pro.
What happens after dropping the Acrobat Reader Icon onto Script Editor.app?
If an application has no AppleScript dictionary, a warning message will be displayed

Adobe Reader has a dictionary. That’s the problem.