printing in applescript using printer presets

Hi there

I’m moving the discussion of the following topic to here, because it actually doesn’t belong to the “Code Exchange” section and because there are a lot more people reading this section.

http://macscripter.net/viewtopic.php?id=25344, think its best if you read it first.

I’m a University-Student and I need to download a lot of PDF’s. Right now I’m already sorting them in different folders using hazel http://www.noodlesoft.com/hazel.php. But I also want to print them automatically using different printer presets, because some files have to be printed in duplex mode, some not, some 2 on 1, some 4 on 1 etc.

I’ve already asked Paul Kim of noodlesoft, but he does not have a solution.

Well there are some printer settings you can adjust using applescript (http://developer.apple.com/technotes/tn2002/tn2082.html) But you can’t do a duplex print or an 4 on 1 pages print.

Thanks for you help!
Simon

im not sure if this will help or not but I have had a reasonable amount of success with using the Unix Printing System and CUPS, see how it works for you.

http://www.cups.org/doc-1.1/sum.html

sample:

do shell script "lp -d HP_LaserJet_52001 -o Landscape -o media=A3,Tray3 -o position=center " & quoted form of (POSIX path of (theFile as alias))

PERFECT!

I can get it to work now! Great…you saved me a lot of time

here’s how I use it

do shell script (getShellCommand("Brother_HL_5250DN_series", 2, 150, true, false, theFile))

on getShellCommand(thePrinter, upNumber, brightness, isDuplex, islandscape, theFile)
	(* arguments description
thePrinter: choose a printer (lpstat -p ENTER, in Terminal, shows all your printer)
upNumber: integer {1,2,4,6,9,16}
isDuplex: boolean, use true or false
brightness: integer, Values greater than 100 will lighten the print, while values less than 100 will darken it
theFile: alias (!) to the File you want to print
also see: http://www.cups.org/doc-1.1/sum.html for more settings
*)
	
	set theCommand to "lp -d " & thePrinter & " -o number-up=" & upNumber & " -o brightness=" & brightness
	if isDuplex then
		if islandscape then
			set theCommand to theCommand & " -o sides=two-sided-short-edge "
		else
			set theCommand to theCommand & " -o sides=two-sided-long-edge "
		end if
	end if
	
	set theCommand to theCommand & quoted form of (POSIX path of (theFile as alias))
	return theCommand
	
end getShellCommand