Scripting Acrobat 7 Pro

Is there any documentation available for AppleScripting Acrobat 7 Pro?
I’m trying to write a script that will open a PDF and use the PDF Optimizer menu to reduce the file size but can’t find anything that makes sense in Acrobat 7 dictionnary. Will I have to use UI scripting to do that?
Thanks!

Browser: Safari 312.3
Operating System: Mac OS X (10.3.9)

I checked the dictionary and it doesn’t look like that is scriptable. I scripted the “PDF Compare” function using UI scripting. I will post my code for that function to give you a starting point. If you want to try it, save this as an application so it can be used as a droplet. Drag two PDFs on the script to run it.

It was a bit aggravating getting the code right to select things from submenus in the main window (all that "of group 1 of group 3 etc…), but I eventually got it to work. Good luck.


on open these_items
	tell application "Finder"
		activate
	end tell
	tell application "System Events"
		if exists process "Acrobat" then
		else
			tell application "Adobe Acrobat 7.0 Profe#5DC"
				activate
				delay 3
			end tell
			tell application "Finder"
				activate
			end tell
		end if
		
		set NumberOfFiles to the count of these_items
		if NumberOfFiles is not 2 then
			display dialog "You must process two PDF files at a time!" buttons "Cancel"
		end if
		
		set the item_info1 to info for item 1 of these_items
		set the item_info2 to info for item 2 of these_items
		
		if (alias of the item_info1 is true) or (alias of the item_info2 is true) then
			display dialog "No aliases, PDF files only." buttons "Cancel"
		end if
		if (kind of item_info1 is "Adobe PDF document" or kind of item_info1 is "PDF document" or kind of item_info1 is "Adobe Photoshop PDF file") and (kind of item_info2 is "Adobe PDF document" or kind of item_info2 is "PDF document" or kind of item_info2 is "Adobe Photoshop PDF file") then
		else
			display dialog "These are not PDF files." buttons "Cancel"
		end if
		
	end tell
	my ComparePDF(item 1 of these_items, item 2 of these_items)
	beep 2
end open

on ComparePDF(item1, item2)
	tell application "Adobe Acrobat 7.0 Profe#5DC"
		activate
		open item1
		open item2
		delay 3
		tell application "System Events"
			tell process "Acrobat"
				pick menu item "Compare Documents..." of menu "Document" of menu bar item "Document" of menu bar 1
				delay 2
				click pop up button 1 of group 1 of group 4 of group 1 of window "Compare Documents"
				key code 126  --up arrow
				key code 126
				key code 126
				key code 126
				key code 126
				key code 36  --return
				click pop up button 1 of group 1 of group 3 of group 1 of window "Compare Documents"
				key code 126
				key code 126
				key code 126
				key code 126
				key code 126
				key code 125 --down arrow to select second open document
				key code 36
				click radio button "Page by page visual differences" of group 1 of group 2 of group 1 of window "Compare Documents"
				click pop up button 1 of group 1 of group 2 of group 1 of window "Compare Documents"
				key code 126
				key code 126
				key code 126
				key code 126
				key code 36
				click radio button "Side by Side Report" of group 1 of group 1 of group 1 of window "Compare Documents"
				click button "OK" of group 1 of window "Compare Documents"
				delay 3
				pick menu item "Compare Documents..." of menu "Document" of menu bar item "Document" of menu bar 1
				delay 2
				click radio button "Textual differences" of group 1 of group 2 of group 1 of window "Compare Documents"
				delay 1
				click checkbox "Include font information (style, size, typeface)" of group 1 of group 2 of group 1 of window "Compare Documents"
				click button "OK" of group 1 of window "Compare Documents"
			end tell
		end tell
	end tell
end ComparePDF


Model: Mac G5
Operating System: Mac OS X (10.3.9)

You could just use Acrobat’s Batch Sequences to run the optimization too.

I haven’t used that before. I just looked and I didn’t see the PDF optimizer or Compre Documents available in there. Is there a way to add functions or are you limited to what comes up? Also, can you easily trigger one from a script?

Its pretty basic you can add functions to it by using the execute java sequence. Just create a new sequence with no commands, set how you want it to run and save to, PDF Optimizer settings are accessed in the output options button. I’ve done very little scripting with this app yet.