Printing PDFs with acrobat 7 using System Events?

I have not done anything with system events scripting but I have heard it is capable of sending commands to otherwise unscriptable apps. The print pages function in acrobat 7 is broken, I want to create a script that goes around it to go through the menus. Preferably without the user interaction box.
Is this possible? If so, could someone give me a starting point (or the whole script if your feeling generous)?
Thanks
Chuck

I’m kinda new to this, but I have a script that goes through the menus in Acrobat 7 to extract all of the pages to separate pdf files in another location. It’s probably not going to be the prettiest thing that you have ever seen, but it’ll show you what I did to get there.

--BEGIN ACROBAT LAUNCH
set appsPath to (path to applications folder as text) & "Adobe Acrobat 7.0 Professional:" -- note the colon
set appName to "Adobe Acrobat 7.0 Professional"
-- right
tell application "Finder"
	try
		open alias (appsPath & appName) -- this
	on error
		set resp to button returned of (display dialog appName & " not found, please find it")
		if resp = "OK" then set f to choose file -- you can choose application too, but it's sloooow
		open f
	end try
end tell
--Many thanks to Adam Bell for this section.
--END ACROBAT LAUNCH

set pressed to "Yes"

--BEGIN REPETITIVE SECTION
repeat until pressed is not "Yes"
	tell application "Adobe Acrobat 7.0 Professional"
		activate
		choose file with prompt "Select PDF to Convert to Single Pages..."
		copy the result to Orgdoc
		open Orgdoc
	end tell
	delay 1
	tell application "Adobe Acrobat 7.0 Professional"
		activate
		set PageCount to ""
		set Orgdoc to the front document
		set PageCount to page count
		
		tell application "System Events"
			tell process "Acrobat"
				click menu item "Number Pages..." of menu "Advanced" of menu bar item "Advanced" of menu bar 1
				delay 1
				tell group 1 of group 2 of group 1 of window "Page Numbering"
					click radio button "All"
				end tell
				delay 0.5
				tell group 1 of window "Page Numbering"
					click button 1
				end tell
			end tell
		end tell
		delay 0.5
		tell application "System Events"
			tell process "Acrobat"
				click menu item "Extract Pages..." of menu "Document" of menu bar item "Document" of menu bar 1
				delay 1
				keystroke tab
				keystroke (PageCount as string)
				delay 0.5
				click checkbox "Extract Pages As Separate Files" of group 1 of window "Extract Pages"
				click button "OK" of group 1 of window "Extract Pages"
			end tell
			set goahead to display dialog "Select Destination for output and Press OK once document is finished extracting. Check the progress bar in the lower left-hand corner of your Acrobat window for extraction status." buttons {"OK", "Not OK"} default button 1
			set goahead2 to button returned of goahead
			if goahead2 is "OK" then
				close Orgdoc saving no
			end if
		end tell
	end tell
	
	tell me
		activate --necessary to display next dialog
	end tell
	
	set temp to display dialog "Would you like to process another PDF?" buttons {"No", "Yes"} default button 2
	set pressed to button returned of temp
end repeat
--END OF REPETITIVE SECTION


--QUIT ACROBAT
tell application "Adobe Acrobat 7.0 Professional"
	quit saving no
end tell

This script only works if you have “Enable access for assistive devices” checked under “Universal Access” in “System Preferences”. It would never have worked if I hadn’t come across these forums.

Also, you’ll have to have the names of the elements you want to interact with in Acrobat, so you might see if you can find UI Element Inspector for download since it beats the pants off of guessing what everything goes by.

I am doing this right now, and it’s pretty simple:


tell application "Adobe Acrobat 7.0 Professional"
     tell application "System Events"
          tell application process "acrobat"
               -- below invokes Command-p, activating File Menu-Print
               key down command
               keystroke "p"
               key up command

               -- to print more than one copy use below, change # to number of copies you want
               -- keystroke "#"

               -- below dismisses dialog
               keystroke return
          end tell
     end tell
end tell

It’s certainly possible to set other parameters on the print dialog as well, but I haven’t gone that far yet.

Also, you have to be sure that your page setup and the other options in the print dialog are set correctly. I recommend saving Custom Settings for both page setup and print dialog options. I’m using the above script to print to an custom page size and I also set the print dialog to “tile large pages”. Acrobat 7 will save these selections even if the machine is restarted.