Adobe Illustrator CS (v 11.0.0) printing postscript via applescript

I can make InDesign print postscript, but Illustrator doesn’t work the same way.
Which is odd considering that Adobe has updated Illustrator’s Print Dialog to mirror InDesign’s.

tell application "Illustrator CS"
	set OldDelims to AppleScript's text item delimiters
	set x to get name of document 1
	set filepath to "DistillerIHT:In" as Unicode text
	set user interaction level to never interact
	--set theStyle to printer preset "IHT"
	tell document 1
		--set active printer preset to theStyle
		--set page range to "1"
		--set printer to postscript file
		--set print file to (x & ".ps")
		--postscript {name: filepath & x}
		print PostScript
	end tell
	set user interaction level to interact with all
end tell

This script, as is, asks for File/Folder, but of course when I try to feed the script that it doesn’t accept it. And I’ve tried many different solutions. None seem to work.

I really appreciate any help that anyone can offer.

bradevans,

Here is some script I just tried. I have piddled with the print stuff out of CS a few times but I think I finally got it. The code here is changed some from your script but should be easily adapted. Hope this helps.


set theC to choose folder
tell application "Finder"
	set cName to theC as string
end tell
tell application "Illustrator CS"
	activate
	set thisDoc to current document
	set user interaction level to interact with all
	set newF to name of current document
	set newFPath to cName & newF & ".ps"
	display dialog newFPath -- this was just to check the path
	set postOpts to {class:postscript options, PostScript:level 2}
	set jobOpts to {class:job options, file path:newFPath}
	set printOpts to {class:print options, job settings:jobOpts, postscript settings:postOpts, printer name:"laserjet 2300 series"}
	print thisDoc options printOpts
end tell

This seemed to give me a postscript file out of Ill CS eventhough I could open it directly in Ill. Distiller did make a pdf.
PreTech

Model: dual 1.8 G5
AppleScript: 2.1 (80)
Browser: Safari 412.5
Operating System: Mac OS X (10.4)

Thanks PreTech.

I’ve only had time to try it out twice. The first time it worked and the second time it said there was no current document open when there was. Odd, right? Anyway, very busy today, so I’ll test and tweek it some more tomorrow.

Thanks again,
Brad


set filepath to "DistillerIHT:In:" as Unicode text
tell application "Finder"
	--set cName to theC as string
end tell
tell application "Illustrator CS"
	activate
	--set thisDoc to current document
	set user interaction level to interact with all
	set thisDoc to name of current document as text
	set FullPath to filepath & thisDoc & ".ps"
	--display dialog newFPath -- this was just to check the path
	set postOpts to {class:postscript options, PostScript:level 2}
	set jobOpts to {class:job options, file path:FullPath}
	set printOpts to {print area:artboard bounds, print as bitmap:true, class:print options, job settings:jobOpts, postscript settings:postOpts, printer name:"Adobe Postscript® File", PPD file:"Adobe PDF"}
	print thisDoc options printOpts
end tell

This script doesn’t work. PreTech, your’s did. The only issue with yours, is the fact that you must interact with it. The idea here is to lessen the amount of work we do in general.

So I went ahead and modified your’s with no luck. Usually that’s a fairly easy task. But I just can’t get this to work for me.

Any insight?

I must apologize, I’ve done this in every major design app in the past but apparently something major has changed or I’ve simply lost my touch :wink:

bradevans,

Here is the code, modified a bit.

I haven’t quite got it to print as a pdf yet. Maybe it’s my computer. Give this a try on yours and see.


set filepath to "MacIntosh HD G52:Users:admin2:Desktop:Test:" as Unicode text
tell application "Finder"
	--set cName to theC as string
end tell
tell application "Illustrator CS"
	activate
	--set thisDoc to current document
	set user interaction level to interact with all
	set thisDoc to name of current document as text
	set FullPath to filepath & thisDoc & ".pdf"
	--display dialog newFPath -- this was just to check the path
	set ppdFileName to "Defauls (Adobe PDF)" as Unicode text
	set postOpts to {class:postscript options, PostScript:level 2}
	set jobOpts to {class:job options, print area:artboard bounds, print as bitmap:true, file path:FullPath}
	set printOpts to {class:print options, job settings:jobOpts, postscript settings:postOpts, printer name:"Adobe PDF", PPD name:ppdFileName}
	print current document options printOpts without dialogs
end tell

PreTech

P.S. On my computer the resulting file looks like an oldstyle Illustrator eps file. Not really a pdf. Still working on it though.
P.P.S. I just noticed that set ppdFileName should be “Default (Adobe PDF)”. However, that doesn’t change things. The resulting file ends up being recoginzed as an Ill 8.0.1 document instead of a pdf. I’m assuming it has something to do with whether or not the printer name is correct or the ppd name is correct. If you leave off the “.pdf” it ends up being a text file.

Your help is greatly appreciated. However, a PDF just won’t do.

The printer that prints this newspaper seems to be in the stone ages with their rip and general process, so I must create a .ps file and the run it through distiller (with their settings) to get a PDF. And 35% of the time, that doesn’t even work.
–Literally, their success rate, when asked of it, is 65% - but that’s on their end :slight_smile:

FYI, my modified version of the script you posted returns "Illustrator CS got an error: Can’t get “0124_gs4.eps”(which it should call from ‘name of current document as text’), which is rediculous because I can do this in other scripts. Very confusing.

The only other thing is that I have had to jump through hoops with applescript’s in my new position here. The security here is unbelievable, I was the assitant to the macintosh server administrator in college, but I don’t understand how they have things set up here. My home directory is on server about 3 miles from my computer. :confused:

bradevans,

If you just need a .ps file, I would use any printer installed that can do post script. I thought you were trying to make a pdf this way. Change .pdf to .ps and leave off the ppd name. It works that way here.

PreTech

I got it!

Shane, you’ve been an extremely valuable resource to me though this. If you’re in New York anytime, hit me up and I’ll buy you lunch!

Thanks again.

Here’s the final code:


set filepath to "DistillerIHT:In:" as Unicode text
tell application "Finder"
	--set cName to theC as string
end tell
tell application "Illustrator CS"
	activate
	--set thisDoc to current document
	set user interaction level to never interact
	set thisDoc to name of current document as text
	set FullPath to filepath & thisDoc & ".ps"
	--display dialog newFPath -- this was just to check the path
	set ppdFileName to "Adobe PDF" as Unicode text
	set postOpts to {class:postscript options, PostScript:level 2}
	
	set jobOpts to {class:job options, print area:artboard bounds, print as bitmap:true, file path:FullPath}
	
	set printOpts to {class:print options, job settings:jobOpts, postscript settings:postOpts, printer name:"Adobe Postscript® File", PPD name:ppdFileName}
	
	print current document options printOpts without dialogs
end tell

Now I’ll simply add a small subroutine to trim the .eps off of the end of the file name for a cleaner look.