Skip to main content
Participant
March 14, 2020
Question

Scripting Illustrator using AppleScript - how to place a PDF file in a specific position and layer

  • March 14, 2020
  • 2 replies
  • 1895 views

Hello -

 

I am trying to automate my image creation pipeline and would like to program up the equivalent of paste (and scale) in illustrator. I am a newbie to scripting, but chose to use AppleScript, and I find the documentation far too sparse to be helpful.

 

My understanding is that I should be able to do this using either group item or placed item. However, if I try

 

set imageRef to make new placed item in imageLayer with properties {file path: imageFileName}

 

where imageLayer is defined using

 

set imageFileName to POSIX file "testFile.pdf"

 

while imageLayer is defined via

 

set imageLayer to layer 1 of docRef

 

However, when I try to execute the script, I get the following error message: "Adobe Illustrator got an error: Can’t make some data into the expected type."

 

Any advice would be very much appreciated! Also, if anyone could point me to the reference to the property fields of different objects, then that would also be very helpful (for example, where can I find the property fields for placed items or group items?

 

Thanks,

 

Carl

This topic has been closed for replies.

2 replies

Participant
June 28, 2020

Hi Carl

 

Did you get this to work as I need to automate placing an image in illustrator as well.

 

AndyC

Inspiring
March 17, 2020

1. File paths must be absolute, e.g. "/Users/carl/testFile.pdf"

 

2. If you’re on AI 2020, the file path must be given as a string:

        set imageFileName to "/Users/carl/testFile.pdf"

   For earlier versions, it must be a file object:

        set imageFileName to POSIX file "/Users/carl/testFile.pdf"

 

3. To view an application’s AppleScript dictionary in Script Editor, choose File > Open Dictionary. PDF-based documentation  (same info, but also includes example scripts) is also available at: www.adobe.com/devnet/illustrator/scripting.html