Print Range of Pages from Acrobat

Updated application is here:

We had a 6088 page PDF from the client where every 8 pages were to be stapled by the copier. We would have had to print each 8 page range, 761 times by hand!

So I wrote this script that sends every 8 page set to the default printer for you.

To test, remember to stop your print que beforehand.

I had to first print a page to set up Tray use, staple location and other critiria. Acrobat remembers the last printer and its settings for subsequent prints.

(*Prints every n pages from acrobat*)

with timeout of 20000 seconds -- 5.55 hours to wait for response from user
	tell application "Finder"
		display dialog "Before continuing, print a page from your Acrobat document to set up printer that you will use to print to." buttons {"Cancel", "OK"} default button 2
	end tell
	tell application "Acrobat 6.0.2 Professional"
		tell active doc
			display dialog "What is the starting page?" default answer ""
			set FirstPage to (the text returned in the result) as number -- Set starting page here
			display dialog "How many pages for each set?" default answer ""
			set StepOff to (((the text returned in the result) as number) - 1) -- The pages in each set to be printed
			set LastPage to FirstPage + StepOff -- This is the last page of the first set. i.e. if the first page is 1, and the range of pages in set was 8, then the last page will be 8 and so on.
			set AllPages to count of pages -- Gets all page in whole doc
			log "AllPages in doc: " & AllPages
			log "LastPage of 1st set: " & LastPage
			log "StepOff: " & StepOff
			log "FirstPage of 1st set: " & FirstPage
			set AllPages to AllPages - FirstPage --pages that are left to print
			log "AllPages in loop: " & AllPages
			set BoolVal to true
			repeat with i from 1 to round (((AllPages / StepOff)) - 1)
				print pages first FirstPage last LastPage
				if BoolVal is true then
					display dialog "Sent: " & FirstPage & " to " & LastPage & ". Continue with next " & (StepOff + 1) & " pages?" buttons {"Cancel", "Don't ask again", "OK"} default button 3 -- Asks user to continue so large page documents can be controlled if printer is needed by other people in office. If not needed you can comment out. 
					if (button returned of result) = "Don't ask again" then set BoolVal to false
				end if
				set FirstPage to FirstPage + StepOff + 1
				set LastPage to LastPage + StepOff + 1
				log "StepOff: " & StepOff
				log "FirstPage of next set: " & FirstPage
				log "LastPage of next set: " & LastPage
				log "Count: " & i
				set i to i + 1
			end repeat
		end tell
	end tell
end timeout

I’m attempting to improve my applescripting abilities. I tested this app on my Mac G4 running Tiger. I have Acrobat Professional 7.0. However, the dictionary items for print pages is the same as for Acrobat 6.

When I run the script I get this error:

“Adobe Acrobat 7.0 Professional got an error: active doc doesn’t understand the print pages message.”

so I tried just a simple:

tell application "Adobe Acrobat 7.0 Professional"
tell active doc
print pages first 1 last 3
end tell
end tell

still got the error. Why might this be happening?


Bit late to solve this problem, but better late than never, especially if you stumble on this from a search :smiley:

Check this:

and this:

for v7 fix