I’m trying to open a series of pdf’s with illustrator (CS3 suite), so I can annote them. However they insist on opening with Acrobat, and the script thinks they’ve opened with Illustrator. Is there a better way of ‘forcing’ the files to open with Illustrator please?
theFile is the path name to the actual pdf. I’ve even embedded the ‘open’ command twice with two ‘tell’ commands, to no avail.
Also, I don’t want to set the default opening program for pdf’s to Illustrator.
Regards
Santa
on PrintWithIllustrator(theFile, BarCodeDateTimeName)
tell application "Adobe Illustrator"
activate
tell application "Adobe Illustrator"
open theFile
end tell
tell application "System Events" to tell process "Adobe Illustrator"
keystroke return
end tell
delay 2
tell document (name of theFile)
set NewText to make new text frame at beginning with properties {kind:point text, contents:BarCodeDateTimeName, position:{20, 20}}
set properties of text of NewText to {font:"IDAutomationHC39M", size:12}
end tell
tell application "System Events" to tell process "Adobe Illustrator"
keystroke "s" using command down
keystroke return
delay 1
keystroke "w" using command down
end tell
end tell
end PrintWithIllustrator
Solved it… stupid error… forgot the ‘file’ in front of theFile
Also, note the addressing format to Illustrator CS3…
You can’t use ‘tell document…’
on PrintWithIllustrator(theFile, BarCodeDateTimeName)
tell application "Adobe Illustrator"
activate
tell application "Adobe Illustrator"
open file theFile
end tell
tell application "System Events" to tell process "Adobe Illustrator"
keystroke return
end tell
delay 2
set NewText to make new text frame at beginning of document 1 with properties {kind:point text, contents:BarCodeDateTimeName, position:{20, 20}}
set properties of text of NewText to {text font:text font "IDAutomationHC39M", size:12}
tell application "System Events" to tell process "Adobe Illustrator"
keystroke "s" using command down
keystroke return
delay 1
keystroke "w" using command down
end tell
end tell
end PrintWithIllustrator
The reason i’m using GUI for illustrator is that I’ve got 1200 lines of code that someone else has to understand, that uses 7 different Apps to open a wide variety of files, prints a sum-up of email cover sheet, save attachments as annoted pdf’s, uses two printers, saves 3 copies to different servers, and prints the PDF’s, all error trapped and operating unattended. I tried to use a direct method of saving Illustrator docs as PDF’s but couldn’t get the syntax right, so decided to use GUI for all apps to be uniform.
As for not using ‘tell window 1’
This doesn’t work because the second line also refers to making a new box, cause it uses the full variable from the first line
tell document (name of theFile)
set NewText to make new text frame at beginning with properties {kind:point text, contents:BarCodeDateTimeName, position:{20, 20}}
set properties of text of NewText to {font:"IDAutomationHC39M", size:12}
end tell
This does work, cause document 1 is referred to seperately. I should also point out that I used a string for the variable theFile
set NewText to make new text frame at beginning of document 1 with properties {kind:point text, contents:BarCodeDateTimeName, position:{20, 20}}
set properties of text of NewText to {text font:text font "IDAutomationHC39M", size:12}
EDIT I had to change ‘tell document (name of theFile)’ to ‘tell document 1’ because sometimes illustrator translates/opens files and changes the name to ‘Untitled x’