G’day scripters.
No help on the net with this, so here goes.
I’m adding text boxes to the top of illustrator documents, but need to resize the art board to cover the new boxes.
I can’t get the terminology right for the ‘fitartboardtoselectedart’ command.
Can anyone guide me on this please?
Regards
Santa
on printIllustrator() try set p to 1 set TempAttachmentName to my ResetAttachmentName() tell application "Finder" set my tempName to name of file (my theItem) as text set my PreserveFileName to tempName end tell tell application "Adobe Illustrator" try activate repeat until the (count of documents) is 0 close every document saving no end repeat set addBarCode to false set my theItem to my theItem as alias try tell application "System Events" to tell process "Adobe Illustrator" try keystroke return end try end tell open my theItem dialogs no -- as alias (don't use 'as alias' or routine won't work) end try repeat 2 times tell application "System Events" to tell process "Adobe Illustrator" try click button "Continue" of window 1 end try try keystroke return end try end tell end repeat set x to 0 set foundAFile to false repeat if exists document 1 then set foundAFile to true exit repeat end if do shell script ("sleep 0.2") set x to x + 1 if x ≥ 400 then exit repeat --try for 40 seconds end repeat set addBarCode to false if my tempName does not contain "_UEI " then set addBarCode to true set p to 2 if addBarCode then set p to 2.1 set bb to visible bounds of document 1 set p to 2.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) + 45)}} 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) + 200), ((item 2 of bb) + 35)}} 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" # set bb to crop marks of document 1 set p to 8 tell application "System Events" to tell process "Adobe Illustrator" keystroke "a" using command down end tell set p to 8.1 set bb to visible bounds of document 1 # This doesn’t crash, but also doesn’t work tell document 1 to fitartboardtoselectedart {} # end if set p to 16 on error errmsg number errnum set my didItPrint to false tell application "System Events" to display dialog "printIllustrator " & return & errmsg & return & "number " & errnum & " p = " & p giving up after 40 end try try activate tell application "System Events" to tell process "Adobe Illustrator" keystroke "p" using command down do shell script ("sleep 0.4") keystroke (character 1 of (my theLargePagePrinter as text)) as text end tell repeat 18 times tell application "System Events" to tell process "Adobe Illustrator" keystroke tab end tell end repeat tell application "System Events" to tell process "Adobe Illustrator" do shell script ("sleep 0.1") keystroke (character 1 of (my theLargePagePrinter as text)) as text do shell script ("sleep 0.1") keystroke return try keystroke return end try end tell end try do shell script ("sleep 0.5") end tell set my theJobsTally to (my theJobsTally) + 1 # Add to printed jobs Tally #my RenameAttachment(my theItem , TempAttachmentName) if addBarCode then if my saveftpFiles then #tell application "Adobe Illustrator" to set my tempName to name of document 1 set newPath to my setUpSavePath("_UEI ftpSaving") as text tell application "Adobe Illustrator" try save document 1 in file newPath end try end tell set end of my preFlightpdfList to newPath if my ftpPrintFlag then set my mailReadyToSend to true end if end if # set my didItPrint to true tell application "Adobe Illustrator" repeat until the (count of documents) is 0 close every document saving no end repeat end tell on error errmsg number errnum set my didItPrint to false my sayTheText("iillustrator error") if errnum = -1728 then set my errorMessage to my errorMessage & "We struck an Illustrator file that refused to open." & return & "It might be that fonts were missing." & return if DialogFlag > 0 then set my errorMessage to my errorMessage & "There were " & DialogFlag & " opening dialogs." & return & return end if tell application "System Events" to display dialog "printIllustrator " & errmsg & return & errnum giving up after 40 tell application "Adobe Illustrator" repeat until the (count of documents) is 0 close every document saving no end repeat end tell end try end printIllustrator
|