I’ve been trying to go at this a number of ways over the last three days, but no luck.
BACKGROUND:
Trying to get Illustrator to print a PostScript file from Illustrator that crops to the edges of the artwork itself (i.e. not using the Document or Page size, but the “geometric bounds.”). This PS file then goes to Distiller to create a PDF. I don’t want to create the PDF from Illustrator directly for a variety of reasons.
Well once I figured out how to get the geometric bounds, no matter how I plug them into the “print options” class, the resulting PostScript file (when run through Distiller) keeps using the page size. Here’s what’s not working:
tell application "Illustrator CS"
--"color management options" class not used
set sep_options to {class:color separation options, convert spot colors:false, over print black:false, separation mode:composite}
set coord_options to {class:coordinate options, emulsion:false, fit to page:false, horizontal scale:100.0, position:center, tiling:single full page, vertical scale:100.0}
--"flattener preset" not used
set flat_options to {class:flattening options, clip complex regions:false, convert strokes to outlines:false, convert text to outlines:false, flattening balance:100, gradient resolution:300.0, overprint:preserve, rasterization resolution:300.0}
set font_options to {class:font options, download fonts:subset, font substitution kind:oblique substitution}
set job_options to {class:job options, bitmap resolution:0.0, collate:false, copies:1, designation:visible printable layers, file path:full_path, print area:artboard bounds, print as bitmap:false, reverse pages:false}
set marks_options to {class:page marks options, color bars:false, page info marks:false, registration marks:false, trim marks:false}
set paper_options to {class:paper options, height:artwork_height, offset:0, transverse:false, width:artwork_width}
set ps_options to {class:postscript options, binary printing:false, compatible shading:false, force continuous tone:false, image compression:none, negative printing:false, PostScript:level 2, shading resolution:300.0}
set ppd_name to "AdobePDF 7.0" as Unicode text
--"print preset" not used
set printer_name to "Adobe Postscript® File" as Unicode text
--full version for reference
set print_options to {class:print options, color separation settings:sep_options, coordinate settings:coord_options, flattener settings:flat_options, font settings:font_options, job settings:job_options, page marks settings:marks_options, postscript settings:ps_options, PPD name:ppd_name, printer name:printer_name}
end tell
In theory, the “paper options” class should be passing on the geometric bounds via artwork_height and artwork_width, but seems to be ignored. I’ve tried changing “artboard bounds” to “artwork bounds” but then Illustrator prints a PS file with most of the objects off the page, no idea why, since doing this manually doesn’t have that effect. Very wierd.
CURRENT PLAN:
So, I’m stepping back and going at this from square-on as a GUI scripting puzzle. Or thought I was. I got stuck before I ever got going. One of the first things I need to set is the Media Size dialog. So far I’ve hit two problems. First was that the menu doesn’t have an assigned name, and seems to change it’s ID for reasons I cannot discern, though it may be related to when “Defined by Driver” was the last choice used. I got around that:
tell application "Illustrator CS"
activate
tell current document
tell application "System Events"
tell process "Illustrator CS"
keystroke "p" using {command down}
--Media:Size: popup ID seems to change from 2 to 3 for reasons I can't discern
if (value of pop up button 2 of window "Print") is "Defined by Driver" then
set media_size_button to 2
else
set media_size_button to 3
end if
end tell
end tell
end tell
end tell
I’m using PreFab’s excellent UU Browser, which helped me figure out the above (bless them for this tool!). But I cannot seem to click, select, or set a value for that popup button. Wierder is usually if there are choices in a menu like that, UI Browser will show them to you, but not for this one. Is it because it’s dynamic and linked to the OS print archecture? Is this why selecting it via the UI is such an issue?
I need to get this popup button to the “Custom” setting so that I can ungrey the Height & Width settings, which are the key for me. In fact, I just explored and those two fields (Height and Width) do not show up in UI Browser (which means playing the “keystroke tab” game to get to them…).
BACKUP PLAN:
I also tried to find a way to get Acrobat Professional to crop the image (i.e. just let Illustrator do it’s crummy default behavior), but unlike Illustrator, Acrobat doesn’t seem to understand individual objects or “geometric bounds” of any sort that I can discern, at least not via AppleScript. The cropping tool and dialog seem to be able to “crop to fit” but I can’t see a way for AppleScript to kick-start these features. I haven’t checked the JavaScript guide yet to see if it’s possible that route. Kinda trying to not to delve into that rat’s nest…
QUESTION:
So that leaves one of three challenges for me:
–Find some way to script the print dialog to pay attention to custom page settings, or…
–Find a way to GUI my way out of it, or…
–Find a way to crop to the geometric bounds after-the-fact with Acrobat
Are we having fun yet? I’m not.
–Kevin
Model: Dual 2.7 GHz G5
AppleScript: (default Tiger 10.6.4)
Browser: Firefox 1.5.0.4
Operating System: Mac OS X (10.4)