G’day scripters.
I’m trying to print an Illustrator file without using the GUI (which in Illustrators case is darn near impossible.
Hoever, direct print on an unedited file works ok, but as soon as I add text boxes, direct printing freezes with ‘Unable to print illustration’.
My full code is below, with a cumbersome method of GUI printing, and the direct printing commented out.
Does anyone know of a way of direct printing an edited Illustrator file please?
Regards
Santa
property theLargePagePrinter : "Quark Printer"
property tempName : "test"
property diditPrint : false
property PreserveFileName : "This is the name part"
property largePaperSize : "A4"
my printIllustrator()
on printIllustrator()
try
set TempAttachmentName to "(2015 03 05 121212Z)"
tell application "Adobe Illustrator"
try
activate
tell current application to delay 0.1
set addBarCode to false
tell application "Finder"
set my tempName to "This is a test" as text
end tell
repeat 2 times
try
tell application "System Events" to tell process "Adobe Illustrator"
click button "Continue" of window 1
end tell
end try
end repeat
set x to 0
repeat until exists document 1
set x to x + 1
tell current application to delay 0.1
end repeat
set addBarCode to false
if my tempName does not contain "_UEI ftpSaving" then set addBarCode to true
set p to 1
if addBarCode then
set p to 1.1
set bb to visible bounds of document 1
set p to 2
set PaperSize to crop marks of document 1
set p to 3
tell document 1
set p to 4
set n to number of layers
repeat with x from 1 to n
set p to 5
set locked of layer x to false
end repeat
end tell
set p to 6
#
# Text Frame 1
#
make new text frame in document 1 with properties {name:"AreaText", contents:TempAttachmentName, position:{(item 1 of bb), ((item 2 of bb) + 40)}}
set p to 6.1
try
make new character style in document 1 with properties {name:"BarCodeBox"}
end try
set p to 6.2
set the size of character style "BarCodeBox" of document 1 to 10
set p to 6.3
apply character style character style "BarCodeBox" of document 1 to the text range of text frame "AreaText" of document 1
set p to 6.4
set the text font of text range of text frame "AreaText" of document 1 to text font "IDAutomationHC39M"
#
# Text Frame 2
#
make new text frame in document 1 with properties {name:"AreaTextTwo", contents:my PreserveFileName, position:{(item 1 of bb), ((item 2 of bb) + 21)}}
set p to 7.1
try
make new character style in document 1 with properties {name:"NameBox"}
end try
set p to 7.2
set the size of character style "NameBox" of document 1 to 12
set p to 7.3
apply character style character style "NameBox" of document 1 to the text range of text frame "AreaTextTwo" of document 1
set p to 7.4
set the text font of text range of text frame "AreaTextTwo" of document 1 to text font "Cochin"
end if
set p to 16
try
(*set printerName to my theLargePagePrinter as string
set paperOptions to {class:paper options, name:largePaperSize}
set jobOptions to {class:job options, designation:all layers} # , print options:printOptions}
set colorOptions to {class:color management options, profile kind:printer profile, intent:perceptual}
set flatOpts to {class:flattening options, clip complex regions:true, gradient resolution:360, rasterization resolution:360}
set printOptions to {class:print options, printer name:printerName, paper settings:paperOptions, flattener settings:flatOpts, job settings:jobOptions, color management settings:colorOptions}
#
# If this can't print, the resultant dialog box is unreadable
#
print document 1 options printOptions
on error errmsg number errnum
tell application "System Events" to display dialog "Error in direct printing illustrator document. " & errmsg & " number " & errnum giving up after 40*)
activate
tell application "System Events" to tell process "Adobe Illustrator"
keystroke "p" using command down
tell current application to delay 0.4
keystroke (character 1 of (my theLargePagePrinter as text)) as text
repeat 18 times
keystroke tab
tell current application to delay 0.1
end repeat
keystroke (character 1 of (my theLargePagePrinter as text)) as text
keystroke return
end tell
on error errmsg number errnum
tell application "System Events" to display dialog "Error in printing illustrator document. " & errmsg & " number " & errnum giving up after 40
end try
tell current application to delay 0.5
on error errmsg number errnum
set my diditPrint to false
tell application "System Events" to display dialog "printIllustrator actual printing " & errmsg & return & errnum & " P = " & p giving up after 40
end try
end tell
end try
end printIllustrator