Getting Acrobat to Print

Greetings!

I’ve been working on a folder action script that should open/print a pdf that’s dropped into it without interaction. I’ve research Adobe & Acrobat and the forums here and I know what the code should look like and what the Acrobat dictionary has in it but the darn thing just won’t work!?! :mad:
When the script runs it generates an error:

Here’s the code:

on adding folder items to printPreflight after receiving listToPrint
	tell application "Finder"
		repeat with currentItem in listToPrint
			set fileName to name of currentItem
			set pathName to printPreflightName & fileName
			if fileName ends with ".pdf" then
				tell application "Adobe Acrobat Professional"
					activate
					open pathName   -- put this in to see if document had to be open for print pages to work
					-- line below has been tried with & without the various qualifiers
					print pages document fileName first 1 last 1 PS Level 1 with binary output and shrink to fit
					-- have also tried the following variaton
					-- print pages document pathName	-- with & without the qualifiers
					quit saving ask
				end tell
			end if
		end repeat
	end tell
end adding folder items to

The ‘print pages’ command is from the Acrobat Viewer Suite section of the dictionary. I’ve tried other commands from there and can’t get them to work either. Commands from the Required & Core Suites seem to work ok but they don’t have the functionality of the commands in the Acrobat Viewer Suite, in particular the ability to print w/o displaying a modal Print dialog box.
Any help, thoughts, etc would be greatly appreciated!! :slight_smile:

Model: MacBook Pro
AppleScript: 1.10.7
Browser: Internet Explorer 7.0
Operating System: Mac OS X (10.4)

Hi,

the script cannot work, because printPreflightName isn’t defined.
Folder actions don’t generate error messages and abort silently

try this


on adding folder items to printPreflight after receiving listToPrint
	repeat with currentItem in listToPrint
		set fileName to name of (info for currentItem)
		if fileName ends with ".pdf" then
			tell application "Adobe Acrobat Professional"
				activate
				open currentItem -- put this in to see if document had to be open for print pages to work
				-- line below has been tried with & without the various qualifiers
				print pages document 1 first 1 last 1 PS Level 1 with binary output and shrink to fit
				-- have also tried the following variaton
				-- print pages document pathName	-- with & without the qualifiers
				quit saving ask
			end tell
		end if
	end repeat
end adding folder items to

if it doesn’t work either change this line, I don’t know, whether Acrobat opens an alias or a string path

open (currentItem as text) -- put this in to see if document had to be open for print pages to work

Sorry… my bad, forgot the first line in my code:

property printPreflightName : "Public:testfolderaction:"

I got the error message by running just the tell application “Adobe Acrobat Professional” part

tell application "Adobe Acrobat Professional"
	activate
	open "Public:testfolderaction:DetailsClassDisplay.pdf"   -- put in actual name/path of file
	-- line below has been tried with & without the various qualifiers
	print pages document "Public:testfolderaction:DetailsClassDisplay.pdf" first 1 last 1 PS Level 1 with binary output and shrink to fit
end tell

Tried the code you suggested:

open (currentItem as text)

didn’t make any difference. The document opens fine with or without ‘as text’ added.
If I use the ‘Print’ command from Acrobat’s Required Suite it works but presents the Print dialog., then someone has to click OK which I want to avoid.
Doesn’t make sense (at least to me…) that the Required & Core Suites work but not the Adobe Viewer Suites. Could something be missing or corrupt?

I know this post is old but maybe this code can help OP or someone else looking like I was.

I was getting the same error “doesn’t understand…”. First off don’t believe the dictionary in Script Editor. All of the parameters are all labeled as optional. I’m pretty sure that they are not. I only cared about shrink page and left out first, last, binary, etc… assuming they default, only to get “doesn’t understand…” error. I finally got rid of the error when I defined all of the parameters.

Last, in the Acrobat SDK, they have “Mac OS - Interapplication Communications” PrintPage sample script file. I was able to copy how they address the print pages command. They set an element of ‘target’ to the ‘active doc’ and address it through there. I’m putting in the pieces that worked on my code into the OPs code. Hopefully this codes works inside of the OPs code. But those little changes took me from the “doesn’t understand…” error to a “you can’t print because you don’t have a pinter” error, and guess what? it’s right… success?!

property printPreflightName : "Public:testfolderaction:"
on adding folder items to printPreflight after receiving listToPrint
	tell application "Finder"
		repeat with currentItem in listToPrint
			set fileName to name of currentItem
			set pathName to printPreflightName & fileName
			if fileName ends with ".pdf" then
				
				-- my Script Editor has been auto writing "Adobe Acrobat" when I try to wrtite "Adobe Acrobat DC". 
				-- Pretty sure Professional is now DC
				tell application "Adobe Acrobat"
					
					activate
					open pathName
					
					try
						-- from the Acrobat SDK sample code
						set target to active doc
						
						-- print pages command reflects sample code now with 'target' and all parameters like before
						print pages target first 1 last 1 PS Level 1 with binary output and shrink to fit
						
						-- reflects the Acrobat SDK sample code with OPs saving ask instead of no
						close target saving ask
						
						return true
					on error e number n
						display dialog e & return & "Error number: " & n
						return false
					end try

					-- adding the quit command outside of the try
					quit
				
				end tell
			end if
		end repeat
	end tell
end adding folder items to
1 Like