Help needed accelerating batch printing from Acrobat 7


Thanks to other posts regarding printing from Acrobat 7 via system events (rather than Acrobat 6’s much easier “print pages”) I have my batch printer droplet working again, with one fairly huge defect.

	on open theFiles

	--sort of theFiles by name
	set files_to_print to ASCII_Sort(theFiles)
		display dialog "How many copies would you like to print: " default answer "1"
	set numCopies to (text returned of result) as string
	repeat numCopies times
		activate application "Adobe Acrobat 7.0 Pro#472F5"
		tell application "System Events"
			tell process "Acrobat"
				repeat with a_file in files_to_print
					tell application "Adobe Acrobat 7.0 Pro" to open (a_file as string)
					delay 2
					click menu item "Print..." of menu "File" of menu bar item "File" of menu bar 1
					delay 2
					click button "Print" of UI element 4 of window "Print"
					delay 5
					tell application "Adobe Acrobat 7.0 Pro" to close all docs saving "No"
				end repeat
			end tell
		end tell
	end repeat
end open

on ASCII_Sort(my_list)
	set the index_list to {}
	set the sorted_list to {}
	repeat (the number of items in my_list) times
		set the low_item to ""
		repeat with i from 1 to (number of items in my_list)
			if i is not in the index_list then
				set this_item to item i of my_list as text
				if the low_item is "" then
					set the low_item to this_item
					set the low_item_index to i
				else if this_item comes before the low_item then
					set the low_item to this_item
					set the low_item_index to i
				end if
			end if
		end repeat
		set the end of sorted_list to the low_item
		set the end of the index_list to the low_item_index
	end repeat
	return the sorted_list
end ASCII_Sort

The delay set just after the print command isn’t sufficient. If the open document takes longer than 5 seconds, the file closes while Acrobat is trying to print it and … well, it’s not good. :wink:

Bumping up the time works, but for some of the longer of our smaller PDF sets, the time for some of the slower computers has needs to be set as long as 25-30 seconds.

Unfortunately, setting it to 30 seconds means it’s waiting 30 seconds for even the 1-page documents, which is no good, as we normally print 7 copies of as many as 20 or 25 pdfs at a time (up to an hour of time “just waiting”).

I’ve checked the dictionary but can’t spot a simple way to check the number of the pages in a document; if there is a way, I could set the delay time to a variable based on two or three seconds per page, which should speed things up considerably.

Alternatively, is there a way to detect when a pdf’s printing is done before starting the next pdf (some way to detect the progress bar, or keep track of which page of the document has been printed)?

Any ideas, or alternate suggestions greatly appreciated.

– Walt Sterdan

After you have opened a document

tell application "Adobe Acrobat 7.0 Professional" to set page_count to count of pages of front document

Thanks, works like a charm!

I had a mental block against using “pages” because it would tell me it didn’t understand “pages” when I said, “print pages”, but “count of pages” seems to be just fine.

Thanks very, very much.

– Walt Sterdan