trouble opening pdf with Illustrator

G’day

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

Hi Santa

Glad you’ve solved your problem!, it is a good feeling when you solve the prob yourself.
Anyhow just a quick question.

Any reason why your using GUI scripting to script the save and close window part of your script???
I don’t have CS3 currently still using CS2.

Just wondered if anything had changed and you couldn’t use the usual syntax to save an illustrator doc and you had to use the GUI route.

also when you say you can’t use the syntax “tell document whatever” is that just for your code or you can’t you use “tell document 1” etc.

I’m sure i’ll get my hands on CS3 at somepoint just wouldn’t mind a little heads up if things have changed a great deal.

cheers

G’day Pidge

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’

Regards

Santa

Thanks Santa!