Illustrator AppleScript Scripting Reference
Illustrator AppleScript Scripting Reference
If this guide is distributed with software that includes an end user agreement, this guide, as well as the software
described in it, is furnished under license and may be used or copied only in accordance with the terms of such license.
Except as permitted by any such license, no part of this guide may be reproduced, stored in a retrieval system, or
transmitted, in any form or by any means, electronic, mechanical, recording, or otherwise, without the prior written
permission of Adobe Incorporated. Please note that the content in this guide is protected under copyright law even if it
is not distributed with software that includes an end user license agreement.
The content of this guide is furnished for informational use only, is subject to change without notice, and should not be
construed as a commitment by Adobe Incorporated. Adobe Incorporated assumes no responsibility or liability for any
errors or inaccuracies that may appear in the informational content contained in this guide.
Please remember that existing artwork or images that you may want to include in your project may be protected under
copyright law. The unauthorized incorporation of such material into your new work could be a violation of the rights of
the copyright owner. Please be sure to obtain any permission required from the copyright owner.
Any references to company names in sample templates are for demonstration purposes only and are not intended to
refer to any actual organization.
Adobe, the Adobe logo, Acrobat, Illustrator, and Photoshop are either registered trademarks or trademarks of Adobe
Incorporated in the United States and/or other countries.
Microsoft and Windows are either registered trademarks or trademarks of Microsoft Corporation in the United States
and/or other countries. Apple, Mac, Macintosh, and Mac OS are trademarks of Apple Computer, Incorporated, registered
in the United States and other countries. JavaScript and all Java-related marks are trademarks or registered trademarks of
Sun Microsystems, Inc. in the United States and other countries. UNIX is a registered trademark of The Open Group.
Adobe Incorporated, 345 Park Avenue, San Jose, California 95110, USA. Notice to U.S. Government End Users. The
Software and Documentation are “Commercial Items,” as that term is defined at 48 C.F.R. §2.101, consisting of
“Commercial Computer Software” and “Commercial Computer Software Documentation,” as such terms are used in 48
C.F.R. §12.212 or 48 C.F.R. §227.7202, as applicable. Consistent with 48 C.F.R. §12.212 or 48 C.F.R. §§227.7202-1 through
227.7202-4, as applicable, the Commercial Computer Software and Commercial Computer Software Documentation are
being licensed to U.S. Government end users (a) only as Commercial Items and (b) with only those rights as are granted
to all other end users pursuant to the terms and conditions herein. Unpublished-rights reserved under the copyright
laws of the United States. Adobe Incorporated, 345 Park Avenue, San Jose, CA 95110-2704, USA. For U.S. Government End
Users, Adobe agrees to comply with all applicable equal opportunity laws including, if appropriate, the provisions of
Executive Order 11246, as amended, Section 402 of the Vietnam Era Veterans Readjustment Assistance Act of 1974 (38
USC 4212), and Section 503 of the Rehabilitation Act of 1973, as amended, and the regulations at 41 CFR Parts 60-1
through 60-60, 60-250, and 60-741. The affirmative action clause and regulations contained in the preceding sentence
shall be incorporated by reference.
Contents
1 AppleScript Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
artboard, artboards . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
AutoCAD export options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
AutoCAD options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
brush, brushes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
character . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
character style, character styles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
CMYK color info . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
color info . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
color management options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
color separation options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
compound path item, compound path items . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
coordinate options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
dataset, datasets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
document, documents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
document preset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
ellipse . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
EPS save options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
ExportForScreens . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
flattening options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
font options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
FreeHand options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
FXG save options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
GIF export options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
gradient, gradients . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
gradient color info . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
gradient stop, gradient stops . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
gradient stop info . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
graph item, graph items . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
graphic style, graphic styles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
gray color info . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71
grid repeat config . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72
grid repeat item, grid repeat items . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
3
Contents 4
This chapter provides a complete, alphaetical reference for the objects and commands in the Adobe®
Illustrator® AppleScript dictionary. For each object, the following information is provided:
Properties of the object, with read-only status, value type, and a description.
Valid commands, with links to sections in Chapter 2, “AppleScript Commands, which describes all
commands in the Illustrator dictionary.
Script examples. These example are intended to illustrate concepts; they do not necessarily represent
the best or most efficient way to construct an AppleScript script. Little error checking was done on
them. They assume that the proper context exists for the scripts to execute in; for instance, that there
is a document open or items selected.
For an overview of the Illustrator object model, see Adobe Illustrator 2025 Scripting Guide.
10
CHAPTER 1: AppleScript Objects application 11
application
The Adobe Illustrator application object, which contains all other Illustrator objects.
application elements
Elements Refer to by
document name, numeric index, range of elements, before/after another element, satisfying a test
text fonts numeric index, range of elements, before/after another element, satisfying a test
color settings list of Unicode text Read-only. The list of color-settings files
currently available for use.
coordinate system Valid values: Coordinate system currently in use.
document coordinate system
artboard coordinate system
application commands
activate
convert sample color
copy
cut
do script
delete workspace
get preset file of
get screen mode
is ruler visible
CHAPTER 1: AppleScript Objects application 14
paste
quit
redraw
reset workspace
save workspace
switch workspace
Select an object
-- Select the first object in the document
tell application "Adobe Illustrator"
-- Make sure there is a page item to select
if (document 1 exists) and (page item 1 of document 1 exists) then
set the selection to page item 1 of document 1
end if
end tell
You do not need to make objects part of the selection to act on them. Selection is useful for moving
objects to and from the clipboard using the cut, copy and paste commands, which act on the current
selection.
Note that Illustrator must be the front-most application when executing commands that involve the
clipboard. This example brings Illustrator to the front using AppleScript’s activate command.
-- Copy current selection to clipboard then paste into a new doc
tell application "Adobe Illustrator"
-- If Illustrator is not the frontmost application, activate it.
if not frontmost then activate
-- Make sure there is a document to copy from
if (count documents) > 0 then
set selectedItems to selection of current document
if selectedItems is not {} then
copy
set colorSpace to color space of current document
make new document with properties {color space:colorSpace}
paste
end if
end if
end tell
CHAPTER 1: AppleScript Objects artboard, artboards 15
artboard, artboards
An artboard object or list of artboard objects. An artboard object represents a single artboard in a
document. There can be between 1 to 100 artboards in one document. You cannot delete the last artboard
in a document.
export file format Valid values: The format to export to. Default: DWG
dxf
DWG
scale lineweights boolean If true, scale line weights by the same scaling
factor as the rest of the drawing. Default: false
scale unit Valid values: Measurement units from which to map.
autocad points
autocad picas
autocad inches
autocad millimeters
autocad centimeters
autocad pixels
AutoCAD options
Options for opening an AutoCAD drawing, used with the open command.
global scale integer The value when global scale option is scale by
percent value, expressed as a percentage. Range: 0.0 to
100.0 Default: 100.0
merge layers boolean If true, the layers of the artwork are merged.
Default: false
scale lineweights boolean If true, scale line weights by the same factor as the
rest of the drawing. Default: false
scale ratio integer The ratio by which to scale while mapping units.
Default: 1.0
scale unit Valid values: The unit to map to. Default: autocad millimeters
autocad points
autocad picas
autocad inches
autocad millimeters
autocad centimeters
autocad pixels
selected layout Unicode text Name of the layout in the drawing to import.
name
CHAPTER 1: AppleScript Objects brush, brushes 18
brush, brushes
A brush or list of brushes. Brushes are contained in document objects. Scripts cannot create new brushes.
Apply brushes
-- Duplicate the current selection (if it is a single item)
-- and apply each available brush to the new object
tell application "Adobe Illustrator" to ¬
set selectedItems to selection
character
Specifies the properties of a character. The text contained within text frames in Illustrator can be accessed
using the character, insertion point, word, line, paragraph, and text classes. The properties and
valid commands for all these classes are similar, but not identical. For example, while character has a
kerning property, the other text classes do not.
Elements Refer to by
character style name, numeric index, range of elements, before/after another element, satisfying
a test
character numeric index, range of elements, before/after another element, satisfying a test
insertion point numeric index, range of elements, before/after another element, satisfying a test
line numeric index, range of elements, before/after another element, satisfying a test
paragraph style name, numeric index, range of elements, before/after another element, satisfying
a test
paragraph numeric index, range of elements, before/after another element, satisfying a test
text numeric index, range of elements, before/after another element, satisfying a test
word numeric index, range of elements, before/after another element, satisfying a test
default type type class Read-only. The default type for the
object’s value.
discretionary boolean If true, use the discretionary ligature.
ligature
CHAPTER 1: AppleScript Objects character 22
Stretch characters
This example demonstrates how to use character properties to create unique effects from a script.
--Distort every character in the first text frame of a document
--by decreasing the horizontal scaling of each character to the midpoint
--then increasing from the mid point to the end (a smaller value here
--means more difference between largest and smallest horizontal
--scaling of the characters)
tell application "Adobe Illustrator"
-- Is there is a document and a text frame to work with
if (exists text frame 1 of current document) then
-- Make sure the text frame contains some text
set textframe to first text frame of current document
if textframe is not "" then -- contains some text
-- Gather info needed to calculate the scale factor
set characterCount to count characters in textframe
set factor to (characterCount + 1) / 2
-- Iterate over each character, changing its horizontal scale
repeat with i from 1 to characterCount
set hScaling to (factor - i) / factor
if hScaling < 0 then set hScaling to -hScaling
set widthScale to 100 + 100 * hScaling
set horizontal scale of character i of text frame 1 of document 1 to
widthScale
end repeat
end if
end if
end tell
CHAPTER 1: AppleScript Objects character style, character styles 27
NOTE: Character attributes do not have default values, and are undefined until explicitly set.
baseline shift real The amount of shift (in points) of the text
baseline.
best type type class Read-only. The best type for the object’s
value.
CHAPTER 1: AppleScript Objects character style, character styles 28
figure style Valid values: Specifies which figure style to use in the
default OpenType font.
proportional
proportional oldstyle
tabular
tabular oldstyle
Character styles
-- Create a document with text frames containing text, then create and apply the same
character style to all
tell application "Adobe Illustrator"
activate
make new document
make new text frame in document 1 with properties {name:"text 1",
contents:"Scripting is fun!", position:{50, 100}}
make new text frame in document 1 with properties {name:"text 2",
contents:"Scripting is easy!", position:{100, 200}}
make new text frame in document 1 with properties {name:"text 3", contents:"Everyone
should script!", position:{150, 300}}
make new character style in document 1 with properties {name:"Big Red"}
set the size of character style "Big Red" of document 1 to 40
set the tracking of character style "Big Red" of document 1 to -50
set the capitalization of character style "Big Red" of document 1 to all caps
set the fill color of character style "Big Red" of document 1 to {class:RGB color
info, red:255, green:0, blue:0}
-- 'apply character style' is the event.
-- 'character style "Big Red" of document 1' is the style applied.
-- note that character styles must be applied to text ranges.
apply character style character style "Big Red" of document 1 to the text range of
text frame "text 1" of document 1
apply character style character style "Big Red" of document 1 to the text range of
text frame "text 2" of document 1
apply character style character style "Big Red" of document 1 to the text range of
text frame "text 3" of document 1
end tell
CHAPTER 1: AppleScript Objects CMYK color info 32
If the color space of a document is RGB and you specify the color value for a page item in that document
using CMYK color info, Illustrator translates the CMYK color specification into an RGB color specification.
The same thing happens if the document’s color space is CMYK and you specify colors using
RGB color info. Since this translation can cause information loss you should specify colors using the color
info class that matches the document’s color space.
color info
An abstract parent class for all color classes used in Illustrator. Subclasses are:
CMYK color info
gradient color info
gray color info
Lab color info
no color info
pattern color info
RGB color info
spot color info
CHAPTER 1: AppleScript Objects color management options 34
All paths in a compound path share property values. Therefore, if you set the value of a property of any one
of the paths in the compound path, all other path’s matching property will be updated to the new value.
Paths contained within a compound path or group in a document are returned as individual paths when a
script asks for the paths contained in the document. However, paths contained in a compound path or
group are not returned when a script asks for the paths in a layer which contains the compound path or
group.
Element Refer to by
path item name, numeric index, range of elements, before/after another element, satisfying a test
Get paths
-- get paths in a document that are not part of a compound path or group
tell application "Adobe Illustrator"
set docRef to current document
set pathItemList to {}
set layerCount to count layers of docRef
coordinate options
The print coordinate options when printing a document with the print command.
tiling Valid values: The page tiling mode. Default: single full page
full pages
imageable areas
single full page
dataset, datasets
An object, or list of objects, that contains variables and their dynamic data.
index integer Read-only. The index of this data set in the art item.
name Unicode text The name of the dataset.
properties record All properties of this object returned as a record.
set the fill color of page item "Rec1" of document 1 to {class:RGB color info,
red:150, green:255, blue:255}
set the contents of text frame "Text1" of document 1 to "Now you see me..."
make new dataset in document 1 with properties {name:"My First Dataset"}
set hidden of page item "Rec1" of document 1 to true
set the contents of text frame "Text1" of document 1 to "Now you don't!"
make new dataset in document 1 with properties {name:"My Second Dataset"}
repeat 3 times
delay 1
display dataset "My First Dataset" of document 1
delay 1
display dataset "My Second Dataset" of document 1
end repeat
end tell
CHAPTER 1: AppleScript Objects document, documents 41
document, documents
An Illustrator document or a list of documents. Documents are contained in the application object.
The default document settings—those properties starting with the word "default"—are global settings
that affect the current document. Be sure to modify these default properties only when a document is
open. Note that if you set default properties to desired values before creating new objects, you can
streamline your scripts, eliminating the need to specify properties such as fill color and stroked that
have analogous default properties.
A document’s color space, height, and width can only be set when the document is created. Once a
document is created, these properties cannot be changed.
Element Refer to by
artboard name, index, before/after, range, test
brush name, index, before/after, range, test
character style name, index, before/after, range, test
compound path item name, index, before/after, range, test
dataset name, index, before/after, range, test
gradient name, index, before/after, range, test
graph item name, index, before/after, range, test
graphic style name, index, before/after, range, test
group item name, index, before/after, range, test
layer name, index, before/after, range, test
legacy text item name, index, before/after, range, test
mesh item name, index, before/after, range, test
non native item name, index, before/after, range, test
page item name, index, before/after, range, test
paragraph style name, index, before/after, range, test
path item name, index, before/after, range, test
pattern name, index, before/after, range, test
placed item name, index, before/after, range, test
plugin item name, index, before/after, range, test
raster item name, index, before/after, range, test
CHAPTER 1: AppleScript Objects document, documents 42
Element Refer to by
spot name, index, before/after, range, test
story index, before/after, range, test
swatch name, index, before/after, range, test
swatch group name, index, before/after, range, test
symbol name, index, before/after, range, test
symbol item name, index, before/after, range, test
tag name, index, before/after, range, test
text frame name, index, before/after, range, test
variable name, index, before/after, range, test
view index, before/after, range, test
crop marks rectangle The boundary of the document’s cropping box for
output.
crop style Valid values: The style of the document’s cropping box.
standard
Japanese style
default stroke dash real The default distance into the dash pattern at which
offset the pattern should be started for new paths.
default stroke dashes list of real Default lengths for dashes and gaps in dashed lines,
numbers starting with the first dash length, followed by the
first gap length, and so on. Set to an empty list, {}, for
a solid line.
default stroke join Valid values: Default type of joints in new paths.
mitered
rounded
beveled
default stroke miter real When default stroke join is set to mitered, this
limit property specifies when the join will be converted to
beveled (squared-off ) by default. The default miter
limit of 4 means that when the length of the point
reaches four times the stroke weight, the join
switches from a miter join to a bevel join. Values: 1 to
500. 1 specifies a bevel join.
default stroke boolean If true, the art beneath a stroked object should be
overprint overprinted by default.
default stroke width real Default width of stroke for new paths.
default stroked boolean If true, new paths should be stroked.
default type type class Read-only. The default type for the document object’s
value. Always returns reference.
file path file specification Read-only. The file associated with the document,
which includes the complete path to the file.
getScreenMode NormalScreenMode Read-only. The mode of display for this view.
FullScreenWithMe
nuMode
FullScreenNoMenu
Mode
PresentationMode
DefaultPreview
geometric bounds rectangle Read-only. The object’s bounds excluding the stroke
width.
CHAPTER 1: AppleScript Objects document, documents 44
ruler origin list The zero-point of the rulers in the document relative
to the bottom left of the document.
ruler units Valid values: Read-only. The default units for the rulers in the
unknown document.
inches
centimeters
points
picas
millimeters
qs
pixels
CHAPTER 1: AppleScript Objects document, documents 45
This example demonstrates how to use document properties in other applications. In this case, the script
uses the file path property of the active document to open the folder containing the Illustrator
document in the Finder.
-- Reveal and select a document’s file icon in the Finder
tell application "Adobe Illustrator"
set filepath to file path of current document
end tell
tell application "Finder"
activate
reveal filepath
end tell
CHAPTER 1: AppleScript Objects document preset 48
document preset
A preset document template to use when creating a new document. See the add document command.
document units Valid values: The ruler units for the new
centimeters document. Default: points
inches
millimeters
picas
points
qs
pixels
unknown
raster resolution Valid values: The raster resolution for the new
screen resolution document.
medium resolution Default: screen resolution
high resolution
CHAPTER 1: AppleScript Objects document preset 49
ellipse
Used to create an elliptical path in an Illustrator document. This object is available only in the context of a
make command, which creates an instance of the path item class. This special class allows you to quickly
create complex path items. Properties associated with path items, such as fill color and note, can also
be specified at the time of creation.
Create ellipses
-- Embellish a single selected path item by adding a bright red
-- ellipse to each point on the path
display dialog "Please select a single path item before running this script"
else
set pathItem to item 1 of selectedItems
This class is used to define a record containing properties that specify options when saving a document as
an EPS file. EPS save options can only be used in conjunction with the save command. It is not possible
to get or create an EPS save options object.
This handler processes a folder of Illustrator files, saving each as an EPS file with level 2 PostScript and
Illustrator 2025 compatibility. The files are save to the folder specified in the destinationFolder
parameter. Note that the class property is specified in the record to ensure that Illustrator can determine
the save option class.
-- Opens files from a predefined source folder in Illustrator
-- then exports them to a predefined destination folder in the chosen format
-- fileList is a list of file names in the source folder
-- filePath is the full path to the source folder
-- destinationFolder is an alias to a folder where the files are to be saved
end if
end ExportFilesAsEPS
CHAPTER 1: AppleScript Objects ExportForScreens 55
ExportForScreens
Options that may be supplied when exporting a document/asset(s)/artboard(s).
withOptions Any Options for the file type specified. For further information,
please refer to JPEG export options, PNG24 export options,
PNG8 export options, SVG export options.
itemtoexport Item to An item that needs to be exported. For example, a document,
export artboard, or asset.
filenameprefix String String prepended to each file name.
CHAPTER 1: AppleScript Objects flattening options 56
flattening options
Specifies transparency flattening options when printing a document with the print command. These
options are used to output artwork that contains transparency into a non-native format.
convert text to outlines boolean If true, all text items are converted to outlines.
Default: false
flattening balance integer The flattening balance. Range: 0 to 100; Default: 100
gradient resolution real The gradient resolution in dots per inch. Range: 1.0
to 9600.0; Default: 300.0
overprint Valid values: Overprint choice. Default: preserve
discard
preserve
Flattening options
-- Activate Illustrator
-- Create a variable that holds the flattening options
-- Create a variable that holds the print options
-- Print the document
tell application "Adobe Illustrator"
activate
set flatOpts to {class:flattening options, clip complex regions:true, gradient
resolution:360, rasterization resolution:360}
set printOpts to {class:print options, flattener settings:flatOpts}
if not (exists document 1) then error "There is no document available to print."
print document 1 options printOpts
end tell
CHAPTER 1: AppleScript Objects font options 57
font options
Font options when printing a document with the print command.
FreeHand options
Options for opening a FreeHand file.
FreeHandFileOptions properties
fxg version Valid values: The version of the FXG file format to create.
version 1.0 Default: version 2.0
version 2.0
This class is used to define a record containing properties that specify options when exporting a document
as a GIF file. GIF export options can only be supplied in conjunction with the export command. It is not
possible to get or create a GIF export options object.
color reduction Valid values: The method used to reduce the number of colors in
selective the document. Default: selective
adaptive
perceptual
web
dither percent integer How much the colors should be dithered. Range: 0 to
100. Default: 88
horizontal scaling real The horizontal scaling factor to apply to the resulting
image. Range: 0.0 to 100.0. Default: 100.0
information loss integer The level of information loss during compression (as a
percentage). Range: 0 to 100. Default: 0
interlaced boolean If true, the resulting image should be interlaced.
Default: false
matte boolean If true, the artboard should be matted with a color.
Default: true
matte color RGB color info The color to use when matting the artboard.
Default: white
saving as HTML boolean If true, the resulting image is saved with an
accompanying HTML file. Default: false
CHAPTER 1: AppleScript Objects GIF export options 61
Export to GIF
This handler processes all Illustrator files in a specific folder, exporting each as a scaled GIF image. Note
that the class property is specified in the record to ensure that Illustrator can determine the export
option class.
-- Opens files from a predefined source folder in Illustrator
-- then exports them to a predefined destination folder in the chosen format
-- fileList is a list of file names in the source folder
-- filePath is the full path to the source folder
-- destinationFolder is an alias to a folder where the files are to be saved
gradient, gradients
A gradient definition or gradient definitions. Gradients are contained in documents. Scripts can create new
gradients.
Element Refer to by
gradient stop index, before/after, range, test
Create a gradient
-- Create a new RGB gradient with three gradient stops
set pGradientName to "RGB Hot Streak"
Gradient information
-- Set fill color of the first path in the current document
-- to the first gradient in the document
tell application "Adobe Illustrator"
set the fill color of path item 1 of document 1 to ¬
{gradient:gradient 1 of document 1}
end tell
CHAPTER 1: AppleScript Objects gradient stop, gradient stops 65
end tell
CHAPTER 1: AppleScript Objects gradient stop info 67
The gradient stops for a new gradient can be specified by providing a list of gradient stop info records
in the entire gradient property. The following applies when creating a gradient from a list of gradient
stop info records:
A gradient stop’s location in the gradient is determined by its ramp point value, not the
gradient stop info record’s order in the entire gradient list.
The midpoint value of the last gradient stop info record in the entire gradient list is not used for the
newly created gradient and need not be provided. If it is present, its value must be in the valid range.
default type type class Read-only. The default type for the graphic style object, which is
reference.
This class is used to define a record which contains the tint value of a gray color. It is used for specifying
and retrieving color information from an Illustrator document or from page items in a document.
row flip type horizontal and Row flip type of grid repeat art.
vertical Default value: no shift or flipcolumn
sf/
horizontalsf/
no
shift or flip/
verticalsf
Paths contained within a group or compound path in a document are returned as individual paths when a
script asks for the paths contained in the document. However, paths contained in a group or compound
path are not returned when a script asks for the paths in a layer which contains the group or compound
path.
A new group can be created that contains the contents of a vector art file if you provide a file specification
to the vector file (EPS or PDF) in the with data parameter of the make command. The resulting group will
be the same object as if the user had placed the file from the user interface using the File > Place
command with the embed checkbox checked.
Element Refer to by
compound path item name, index, before/after, range, test
graph item name, index, before/after, range, test
group item name, index, before/after, range, test
legacy text item name, index, before/after, range, test
mesh item name, index, before/after, range, test
non native item name, index, before/after, range, test
page item name, index, before/after, range, test
path item name, index, before/after, range, test
placed item name, index, before/after, range, test
plugin item name, index, before/after, range, test
raster item name, index, before/after, range, test
symbol item name, index, before/after, range, test
text frame name, index, before/after, range, test
-- Call handler
set fileRef to choose file with prompt "Select vector file to place"
set groupRef to EmbedVectorFile(fileRef)
This script demonstrates how easily new groups can be created and populated with objects.
-- Create a new group, then add rectangles to it using
-- the available placement options
tell application "Adobe Illustrator"
set groupRef to make new group item in document 1
set rectRef to make new rectangle at beginning of groupRef with properties Â
{bounds:{150, 550, 350, 350}, fill color:{blue:255}}
make new rectangle after rectRef with properties Â
{bounds:{100, 600, 300, 400}, fill color:{red:255}}
set rectRef to make new rectangle at end of groupRef with properties Â
{bounds:{0, 700, 200, 500}, fill color:{green:255}}
make new rectangle before rectRef with properties Â
{bounds:{50, 650, 250, 450}, fill color:{black:100}}
end tell
CHAPTER 1: AppleScript Objects group item, group items 77
This example shows how to create a clipping mask using the first path item in a group item. This is the
same effect as you get when you use the Object > Clipping Mask > Make command in the user interface.
-- Create a group of paths, then clip the group to the first path in the group
tell application "Adobe Illustrator"
-- Get a little fancy and create a rotated star at the center of the group
set pathRef to make new star at beginning of groupRef with properties ¬
{center point:{300, 250}, radius:25, inner radius:4, point count:4 ¬
, fill color:{black:100}, opacity:40, stroked:false}
set rotationMatrix to get rotation matrix angle 45
transform pathRef using rotationMatrix about center
Illustrator preferences
Specifies the preferred options for AutoCAD, FreeHand, PDF, and Photoshop files.
NOTE: Preference keys other than those documented in AIPreferenceKeys.h are subject to change
without notice and should not be used.
This class is used to define a record containing properties used to specify options when saving a document
as an Illustrator file. Illustrator save options can only be supplied in conjunction with the save
command. It is not possible to get or create an Illustrator save options object.
Valid commands
save
This handler processes a folder of Illustrator files, saving each with Illustrator 7 compatibility. Note that the
class property is specified in the record to ensure that Illustrator can determine the save option class.
ImageCaptureOptions properties
ink
Specifies the properties of the inks to be used in printing the document.
ink properties
Information about ink use when printing a document with the print command.
trapping order integer The order of trapping for the ink. Range: 1 to 4 for CMYK
CHAPTER 1: AppleScript Objects insertion point 85
insertion point
A location between characters, used to insert new text objects.
An insertion point is logically located between two characters in a text frame. Each insertion point is
before the corresponding character in a text frame. Insertion point 1 is before character 1, etc.
The properties of an insertion point are the same as the character at the same position in the text frame.
For example, the font for insertion point 2 of text frame 1 will be the same as the font for character 2 of text
frame 1.
You can set the properties for an insertion point, but setting only the contents property has no affect on
the text frame. The result of setting the contents of an insertion point to a string value is to insert the string
in the text frame at the insertion point’s location. Setting the contents to an empty string has no affect.
Elements Refer to by
character style name, numeric index, range of elements, before/after another element, satisfying
a test
character numeric index, range of elements, before/after another element, satisfying a test
insertion point numeric index, range of elements, before/after another element, satisfying a test
line numeric index, range of elements, before/after another element, satisfying a test
paragraph style name, numeric index, range of elements, before/after another element, satisfying
a test
paragraph numeric index, range of elements, before/after another element, satisfying a test
text numeric index, range of elements, before/after another element, satisfying a test
word numeric index, range of elements, before/after another element, satisfying a test
job options
The print job options when printing a document with the print command.
This class is used to define a record containing properties that specify options when exporting a document
as a JPEG file. JPEG export options can only be supplied in conjunction with the export command. It is
not possible to get or create a JPEG export options object.
Export to JPEG
This handler processes all Illustrator files in a specific folder, exporting each file as a medium-quality JPEG
image. Note that the class property is specified in the record to ensure that Illustrator can determine the
export option class.
-- Opens files from a predefined source folder in Illustrator
-- then exports them to a predefined destination folder in the chosen format
-- fileList is a list of file names in the source folder
-- filePath is the full path to the source folder
-- destinationFolder is an alias to a folder where the files are to be saved
layer, layers
A layer or list of layers. Layers may contain nested layers, which are called sublayers in the user interface.
The layer object contains all the page items in the specific layer as elements. Your script can access page
items as elements of either the layer object or as elements of the document object. When accessing page
items as elements of a layer, only objects in that layer can be accessed. To access page items throughout
the entire document, be sure to refer to them as elements of the document.
Element Refer to by
compound path item name, index, before/after, range, test
graph item name, index, before/after, range, test
group item name, index, before/after, range, test
layer name, index, before/after, range, test
legacy text item name, index, before/after, range, test
mesh item name, index, before/after, range, test
non native item name, index, before/after, range, test
page item name, index, before/after, range, test
path item name, index, before/after, range, test
placed item name, index, before/after, range, test
plugin item name, index, before/after, range, test
raster item name, index, before/after, range, test
symbol item name, index, before/after, range, test
text frame name, index, before/after, range, test
CHAPTER 1: AppleScript Objects layer, layers 93
class type class Read-only. The layer object’s class, which is layer.
color RGB color info The layer’s selection mark color.
container object reference Read-only. A reference to the document that contains this
layer.
default type type class Read-only. The default type for the layer object’s value.
Always returns reference.
dim placed boolean If true, placed images are to be rendered as dimmed in this
images layer.
has selected boolean If true, one or more objects in this layer selected are
artwork selected; setting this property to false deselects all
objects in the layer.
index integer Read-only. The position of this layer in the current stacking
order of layers in this document, where layer 1 is always
the topmost layer in the stacking order.
isolated boolean If true, this object is isolated
knockout Valid values: Is this object used to create a knockout.
unknown
disabled
enabled
inherited
Move layers
-- Move the 2nd layer to the top of the stacking order
tell application "Adobe Illustrator"
if (count layers of current document) > 1 then
move layer 2 of document 1 to before layer 1 of document 1
end if
end tell
Create a layer
Commands that deal with changes to an object’s reference, including the creation of new objects with the
make command, return a reference to the new or modified object in their result. This example stores the
reference returned for a newly created layer and then creates a new path item in the layer using the
reference.
-- Make a new layer at the top of the layer stack
-- then create a new path in the layer
tell application "Adobe Illustrator"
set layerRef to make layer at document 1 with properties {name:"Our Layer"}
make new rectangle at beginning of layerRef
end tell
CHAPTER 1: AppleScript Objects layer, layers 95
Delete layers
This example demonstrates the power of constructing simple tests (with the whose clause) to selectively
delete layers in a document based on their names. In this case, the script deletes all layers in the current
document that have names starting with the word “Temporary.”
-- Delete layers that have a name which begin with a particular string
set partialName to "Temp"
tell application "Adobe Illustrator"
delete (every layer of document 1 whose name starts with partialName)
end tell
CHAPTER 1: AppleScript Objects legacy text item, legacy text items 96
You can view, move, and print legacy text, but you cannot edit it. Legacy text has an "x" through its
bounding box when selected.
line
A line or lines of text in a text frame. A document’s text can be accessed using the character, insertion
point, word, line, paragraph, and text classes.
Lines of text cannot be created. When the contents property of a text frame is modified, Illustrator will
create text lines as it reflows the text within the text frame.
Elements Refer to by
character style name, numeric index, range of elements, before/after another element, satisfying
a test
character numeric index, range of elements, before/after another element, satisfying a test
insertion point numeric index, range of elements, before/after another element, satisfying a test
line numeric index, range of elements, before/after another element, satisfying a test
paragraph style name, numeric index, range of elements, before/after another element, satisfying
a test
paragraph numeric index, range of elements, before/after another element, satisfying a test
text numeric index, range of elements, before/after another element, satisfying a test
word numeric index, range of elements, before/after another element, satisfying a test
default type type class Read-only. The default type for the
object’s value.
discretionary boolean If true, use the discretionary ligature.
ligature
CHAPTER 1: AppleScript Objects line 99
Lines of text can be located with matching characteristics using the whose clause, as this script
demonstrates.
-- Color red all lines of text containing more than 10 characters
tell application "Adobe Illustrator"
if (count text frames in document 1) > 0 then
set textItemCount to count text frames in document 1
repeat with i from 1 to textItemCount
set (fill color of every line of text frame i of document 1 ¬
whose length > 10) to {red:255.0}
end repeat
end if
end tell
CHAPTER 1: AppleScript Objects matrix 103
matrix
A transformation matrix specification, used to transform the geometry of objects.
Matrices are used in conjunction with the transform command and as a property of a number of objects.
You can generate an original matrix using the get identity matrix, get translation matrix,
get scale matrix, or get rotation matrix commands.
A matrix is a record containing the matrix values, not a reference to a matrix object. The matrix
commands listed above operate on the values of a matrix record. If a command modifies a matrix, a
modified matrix record is returned as the result of the command. The original matrix record passed to the
command is not modified.
A matrix can be generated to effect a scale transformation using the get scale matrix command.
-- Scale all art in a document to 50% vertical size
tell application "Adobe Illustrator"
if (count page items in document 1) > 0 then
set scaleMatrix to get scale matrix horizontal scale 100.0 vertical scale 50.0
transform every page item in document 1 using scaleMatrix
end if
end tell
CHAPTER 1: AppleScript Objects matrix 104
To apply multiple transformations to objects, it is more efficient to use the matrix suite than to apply the
transformations one at a time. The following script demonstrates how to combine multiple matrices.
-- Scale, rotate, and translate all art in a document
tell application "Adobe Illustrator"
if (count page items in document 1) > 0 then
set matrixDef to ¬
get scale matrix horizontal scale 100.0 vertical scale 50.0
set matrixDef to ¬
concatenate rotation matrix matrixDef angle -45.0
set matrixDef to ¬
concatenate translation matrix matrixDef delta x 50.0 delta y -50.0
transform every page item in document 1 using matrixDef
end if
end tell
CHAPTER 1: AppleScript Objects mesh item, mesh items 105
no color info
Represents the “none” color. Assigning a reference to a no color object to a document’s default fill or
stroke color, or those of an art item, is equivalent to setting their filled or stroked property to false.
This class inherits all properties from the color info class.
open options
Specifies options that can be supplied when opening a file.
The page item class gives you complete access to every art item contained in an Illustrator document. The
page item class is the superclass of all artwork objects in a document. The compound path item,
group item, mesh item, non native item, path item, placed item, plugin item, raster item, and
text frame classes each inherit a set of properties from the page item class.
You cannot create a page item directly, you must create one of the specific page item subclasses, such as
path item.
Element Refer to by
tag name, index, before/after, range, test
class type class Read-only. The page item object’s class, which can be any
one of the specific classes that are children of the page item
class, including compound path item, group item, mesh
item, non native item, path item, placed item, plugin
item, raster item, and text frame.
container object reference Read-only. A reference to the layer that contains this page
item.
CHAPTER 1: AppleScript Objects page item, page items 110
height real The height of the page item, calculated from the geometric
bounds.
hidden boolean If true, this page item is hidden.
index integer Read-only. The position of this page item in the current
stacking order of the containing layer, where page item 1 is
always topmost.
isolated boolean If true, this object is isolated.
knockout Valid values: Is this object used to create a knockout.
unknown
disabled
enabled
inherited
layer object reference Read-only. The layer to which this page item belongs.
locked boolean If true, this page item is locked.
name Unicode text The name of this page item.
note Unicode text The note assigned to this item.
opacity real The opacity of this object, where 100.0 is completely
opaque and 0.0 is completely transparent.
pixel aligned boolean True if the item is aligned to the pixel grid.
position fixed point The position (in points) of the top left corner of the item in
the format {x, y}. Does not include stroke weight.
properties record All properties of this object returned as a record.
selected boolean If true, this object is selected.
sliced boolean If true, preserve slices.
URL Unicode text The value of the Adobe URL tag assigned to this page item.
visibility anything The visibility variable to which this page item path is
variable bound.
visible bounds rectangle Read-only. The object’s visible bounds, including stroke
width of any objects in the illustration.
CHAPTER 1: AppleScript Objects page item, page items 111
The stacking order of existing page items in a layer can be manipulated using the move command. This
example demonstrates how to move a page item to the top of the stacking order (index position 1) in a
layer.
-- This script moves all objects in a document to the first layer
tell application "Adobe Illustrator"
set allPageItems to every page item of document 1
move allPageItems to beginning of layer 1 of document 1
end tell
CHAPTER 1: AppleScript Objects page marks options 112
registration marks boolean If true, the registration marks are printed. Default: false
trim marks boolean If true, printing of trim marks is enabled. Default: false
trim marks weight real Stroke weight of trim marks. Minimum: 0.0. Default: 0.125
paper
This class contains information about the paper to be used when printing a document with the print
command.
paper options
Information about the paper options when printing a document with the print command.
paper properties
Information about the paper.
Paper size
-- Make new document
-- Make a rectangle and apply a graphic style
-- Get the printer name of the first printer
-- Get the paper name of the first paper of the first printer
-- Print the document to the printer using the paper name as its paper option
tell application "Adobe Illustrator"
activate
make new document
make new rectangle in document 1 with properties {position:{200, 600}, height:400,
width:100}
apply graphic style 2 of document 1 to path item 1 of document 1
if printers is not {} then
set printerName to (name of item 1 of printers) as string
set printerRef to item 1 of printers
if paper sizes of properties of printerRef is not {} then
set paperName to name of item 1 of paper sizes of properties of (get
properties of item 1 of printers)
set paperOptions to {class:paper options, name:paperName}
set printOptions to {class:print options, printer name:printerName, paper
settings:paperOptions}
print document 1 options printOptions
end if
end if
end tell
CHAPTER 1: AppleScript Objects paragraph, paragraphs 116
paragraph, paragraphs
A paragraph or list of paragraphs of text in the contents of a text art item. A document’s text can be
accessed using the character, insertion point, word, line, paragraph and text classes. All text is
contained within text frames.
The paragraph class has additional properties that other related classes do not share, including properties
for margins, tab stop settings, hyphenation, and word/letter spacing.
Elements Refer to by
character style name, numeric index, range of elements, before/after another element, satisfying a
test
character numeric index, range of elements, before/after another element, satisfying a test
insertion point numeric index, range of elements, before/after another element, satisfying a test
line numeric index, range of elements, before/after another element, satisfying a test
paragraph style name, numeric index, range of elements, before/after another element, satisfying a
test
paragraph numeric index, range of elements, before/after another element, satisfying a test
text numeric index, range of elements, before/after another element, satisfying a test
word numeric index, range of elements, before/after another element, satisfying a test
The hyphenation of all text can be quickly changed from a script, as this example shows.
-- Enable hyphenation for every paragraph of the current document
tell application "Adobe Illustrator"
if (count text frames of document 1) > 0 then
set itemCounter to count text frames of document 1
repeat with i from 1 to itemCounter
set hyphenation of (every paragraph of text frame i of document 1) to true
end repeat
end if
end tell
CHAPTER 1: AppleScript Objects paragraph, paragraphs 125
NOTE: Paragraph attributes do not have default values, and they are undefined until explicitly set.
The path items class gives you complete access to paths in Illustrator.
Element Refer to by
path point index, before/after, range, test
stroke color color info The stroke color for the path.
stroke dash real The default distance into the dash pattern at which the pattern
offset should be started
stroke dashes list of real The lengths for dashes and gaps in dashed lines, starting with the
numbers first dash length, followed by the first gap length, and so on. Set to
an empty list, {}, for a solid line.
stroke join Valid values: Type of join for the path.
mitered
rounded
beveled
stroke miter real When default stroke join is set to mitered, specifies when the join
limit will be converted to beveled (squared-off ) by default. The default
miter limit of 4 means that when the length of the point reaches
four times the stroke weight, the join switches from a miter join to
a bevel join. Values: 1 to 500. 1 specifies a bevel join.
stroke boolean If true, the art beneath the stroked object should be overprinted.
overprint
right direction fixed point The position of a path point’s left direction point (out position).
pattern, patterns
An Illustrator pattern definition contained in a document. Patterns are shown in the Swatches palette.
Each pattern is referenced by a pattern color info object, which defines the pattern’s appearance.
default type type class Read-only. The default type for the pattern object’s value.
Always returns reference.
index integer Read-only. The position of this pattern in the application.
name Unicode text The pattern name.
properties record All properties of this object returned as a record.
reflect angle real The axis (in degrees) around which to reflect. Default: 0.0
rotation real The angle (in degrees) to rotate the prototype pattern before
filling. Default: 0.0
scale factor fixed point The horizontal and vertical scaling to scale the prototype pattern
expressed as a fixed point. Default: 0.0
shear angle real The angle (in degrees) to slant the shear by. Default: 0.0
shear axis real The axis (in degrees) to be used for shearing. Default: 0.0
shift angle real The angle (in degrees) to translate the unscaled prototype
pattern before filling. Default: 0.0
shift distance real The distance to translate the unscaled prototype pattern before
filling. Default: 0.0
PDF options
Options that can be supplied when opening a PDF file.
Preset options can be exported from and imported to a document; see the export PDF preset and
import PDF preset commands.
color profile Valid values: Optional. PDF color profile inclusion policy.
id include all profiles Default: none
include all rgb
include dest profile
leave profile unchanged
none
color resample Valid values: Optional. How color bitmap images should
average downsampling be resampled. Default: nodownsample
bicubic downsample
nodownsample
subsampling
color tile size integer Optional. Tile size when compressing with
JPEG2000. Default: 256
compatibility Valid values: Optional. The version of the Acrobat file
Acrobat 4 format to create. Default: Acrobat 5
Acrobat 5
Acrobat 6
Acrobat 7
Acrobat 8
compress art boolean Optional. If true, the line art and text should
be compressed. Default: true
CHAPTER 1: AppleScript Objects PDF save options 144
Save to PDF
This handler processes a folder of Illustrator files, saving each file as a PDF file, with Illustrator editability
and Acrobat® 6 compatibility. Note that the class property is specified in the record to ensure that
Illustrator can determine the save option class.
-- Opens files from a predefined source folder in Illustrator
-- then exports them to a predefined destination folder in the chosen format
-- fileList is a list of file names in the source folder
-- filePath is the full path to the source folder
-- destFolder is an alias to a folder where the files are to be saved
This class contains properties that specify options when exporting a document as a Photoshop file.
Photoshop export options can only be supplied in conjunction with the export command. It is not
possible to get or create a Photoshop export options object.
editable text boolean If true, text objects should be exported as editable text layers.
Default: true
embed ICC boolean If true, an ICC profile should be embedded in the exported image.
profile Default: false
maximum boolean If true, preserve as much of the original document’s structure as
editability possible. Default: true
resolution real Specifies the resolution of the exported image in dots per inch.
Default: 150.0
save multiple boolean If true, all artboards or range of artboards are saved.
artboards Default: false
warnings boolean If true, a warning dialog should be displayed because of conflicts
in the export settings. Default: true
write layers boolean If true, the layers of the Illustrator document should be preserved
in the exported image. Default: true
CHAPTER 1: AppleScript Objects Photoshop export options 149
This handler saves all files in a folder as layered Photoshop files. Note that the class property is specified
in the record to ensure that Illustrator can determine the save option class.
-- Opens files from a predefined source folder in Illustrator
-- then exports them to a predefined destination folder in the chosen format
-- fileList is a list of file names in the source folder
-- filePath is the full path to the source folder
-- destFolder is an alias to a folder where the files are to be saved
Photoshop options
You can supply options when opening a Photoshop file. See the open command in the command
reference for additional details.
content anything The content variable to which this placed item is bound.
variable
It is not necessary to set the type of the content variable before
binding. Illustrator automatically sets the type to image.
file path file specification The file containing the placed artwork.
matrix matrix The transformation matrix applied to the placed item.
properties record All properties of this object returned as a record.
This class contains properties that specify options when exporting a document as a PNG8 file.
PNG8 export options can only be supplied in conjunction with the export command. It is not possible to
get or create a PNG8 export options object.
color reduction Valid values: The method used to reduce the number of colors in the
selective document. Default: selective
adaptive
perceptual
web
dither percent integer How much should the colors be dithered as a percentage.
Range: 0 to 100. Default: 88
horizontal real The percentage horizontal scaling factor to apply to the
scaling resulting image. Range: 0.0 to 100.0 Default: 100.0
interlaced boolean If true, the resulting image be should be interlaced.
Default: false
matte boolean If true, the artboard should be matted with a color.
Default: true
matte color RGB color info The color to use when matting the artboard.
Default: white
saving as HTML boolean If true, the resulting image should be saved with an
accompanying HTML file. Default: false
transparency boolean If true, the resulting image should use transparency.
Default: true
CHAPTER 1: AppleScript Objects PNG8 export options 154
Export to PNG8
This handler saves all files in a folder as 8-bit PNG files in HTML format with dithering and interlacing. The
class property is specified in the record to ensure that Illustrator can determine the save option class.
This class contains properties that specify options to be used when exporting a document as a PNG24 file.
PNG24 export options can only be supplied in conjunction with the export command. It is not possible
to get or create a PNG24 export options object.
Exporting to PNG24
This handler saves all files in a folder as 24-bit PNG files in HTML format scaled to 50%. Note that the class
property is specified in the record to ensure that Illustrator can determine the save option class.
-- Opens files from a predefined source folder in Illustrator
-- then exports them to a predefined destination folder in the chosen format
-- fileList is a list of file names in the source folder
-- filePath is the full path to the source folder
-- destFolder is an alias to a folder where the files are to be saved
polygon
A class used to create a multi-sided path item in an Illustrator document. This object is available only in the
context of a make command, which creates an instance of the path item class. This special class allows you
to quickly create complex path items using the properties provided. Properties usually associated with
path items, such as fill color, can also be specified at the time of creation.
If you do not specify any properties when making a new polygon, default values are used.
Create a polygon
-- Make an octagon in document 1
tell application "Adobe Illustrator"
set pathRef to make new polygon in document 1 with properties ¬
{center point:{200.0, 200.0}, radius:40.0, sides:8}
end tell
CHAPTER 1: AppleScript Objects postscript options 158
postscript options
Specifies the options for printing to a PostScript language printer or image setter when printing a
document with the print command.
PPD file
Associates properties with a PPD file to be used in printing to a PostScript language printer or image setter.
The properties are not available unless a document is open.
Save to PPD
-- Make a new document
-- Get the PPDs
-- Get the name, PS Level, and file path of the first PPD
-- Make a new text frame with the PPD info as its contents
tell application "Adobe Illustrator"
activate
make new document
set PPDFiles to PPDs
set PPDName to name of item 1 of PPDFiles
set PPDProperties to get properties of item 1 of PPDFiles
set PPDLevel to language level of PPDProperties
set PPDPath to file path of PPDProperties
set textContents to PPDName & return & "PostScript Level " & PPDLevel & return & "PPD
Path: " & PPDPath as string
make new text frame in document 1 with properties {contents:textContents,
position:{20, 600}}
end tell
CHAPTER 1: AppleScript Objects PPD properties 160
PPD properties
Specifies information about a PPD file.
print options
Collects all print options when printing a document with the print command.
end repeat
set jobOptions to {class:job options, designation:all layers, reverse pages:true} ¬
set printOptions to ¬
¬
{class:print options, job settings:jobOptions, color management
settings:colorOptions, coordinate settings:coordinateOptions, flattener
settings:flatteningOptions} ¬
printer
Associates an installed printer with a printer configuration object.
Listing printers
-- Make a new documet
-- Get the name of every printer
-- Display the list of names
tell application "Adobe Illustrator"
set printerList to ""
activate
make new document
set textRef to make new text frame in current document
if printers is not {} then
name of every item of printers as list
repeat with theName in the result
set printerList to printerList & theName & return
end repeat
set theText to printerList
set position of textRef to {200, 600}
else
set theText to "No installed printers"
end if
set contents of textRef to theText
end tell
CHAPTER 1: AppleScript Objects printer properties 165
printer properties
Specifies configuration information for a printer.
custom paper sizes boolean If true, the printer supports custom paper
sizes.
custom paper boolean If true, the printer supports custom paper
transverse transverse.
default resolution real The printer’s default resolution.
Minimum: 0.0
InRIP separation boolean If true, the printer supports InRIP color
support separation.
maximum height offset real The custom paper’s maximum height
offset.
maximum paper height real Custom paper’s maximum height.
maximum paper width real Custom paper’s maximum width.
maximum resolution real The printer’s maximum device resolution.
Minimum: 0.0
maximum width offset real Custom paper’s maximum width offset.
minimum height offset real Custom paper’s minimum height offset.
minimum paper height real Custom paper’s minimum height.
minimum paper width real Custom paper’s minimum width.
minimum width offset real Custom paper’s minimum width offset.
paper sizes list of paper A list of supported paper sizes.
CHAPTER 1: AppleScript Objects printer properties 166
convert spot colors boolean If true, all spot colors are converted to
process colors for the image. Default: false
padding real The amount of white space (in points) added
around the object during rasterization.
Default: .0
resolution real The resolution in dots per inch (dpi).
Range: 72.0 to 2400.0. Default: 300.0
transparency boolean If true, the image uses transparancy.
Default: false
CHAPTER 1: AppleScript Objects raster item, raster items 171
colorants list of Unicode text Read-only. The colorant used in the raster art.
colorized boolean Read-only. If true, the raster art is a colorized grayscale image.
content anything The contents of the variable to which this raster item is bound. It
variable is not necessary to set the type of the content variable
before binding. Illustrator automatically sets the type to image.
embedded boolean If true, the raster item is embedded within the illustration.
file path file specification Read-only. The file containing the raster item, if it is stored
externally.
matrix matrix The transformation matrix of the raster art item.
overprint boolean If true, the raster art is overprinting.
properties record All properties of this object returned as a record.
status Valid values: Read-only. The status of the linked image, if the image is stored
no data externally.
data from file
modified data
rasterize options
Specifies options that may be supplied when rasterizing artwork. All properties are optional.
convert spot colors boolean If true, spot colors are converted to process
colors for the image. Default: false
convert text to boolean If true, all text is converted to outlines before
outlines rasterization. Default: false
include layers boolean If true, the resulting image incorporates
layer attributes (like opacity and blend
mode). Default: false
padding real The amount of white space (in points) added
around the object during rasterization.
Default: .0
resolution real The rasterization resolution in dots per inch
(dpi). Range: 72.0 to 2400.0. Default: 300.0
transparency boolean If true, the image uses transparency.
Default: false
CHAPTER 1: AppleScript Objects rectangle 174
rectangle
A class used to create a rectangular path in an Illustrator document. This object is available only in the
context of a make command, which creates an instance of the path item class. This special class allows you
to quickly create complex path items. Properties associated with path items, such as fill color and
note, can also be specified at the time of creation.
A rectangle is stored as a list of four real numbers, where the first item is the leftmost horizontal coordinate
of the rectangle, the second item is the top vertical coordinate of the rectangle, the third item is the
rightmost horizontal coordinate, and the fourth item is the bottom vertical coordinate of the rectangle.
In the Illustrator coordinate system, vertical coordinates increase from bottom to top, which is the
opposite of screen coordinates. This mean that the top coordinate value in a rectangle is larger than the
bottom coordinate value.
Creating a rectangle
-- Make a square in document 1
tell application "Adobe Illustrator"
make new document
set pathRef to make new rectangle at beginning of document 1 ¬
with properties {bounds:{50.0, 200.0, 200.0, 50.0}, note:"square"}
end tell
CHAPTER 1: AppleScript Objects rectangle 175
If the color space of a document is CMYK and you specify the color value for a page item in that document
using RGB color info, Illustrator will translate the RGB color specification into a CMYK color specification.
The same thing happens if the document’s color space is RGB and you specify colors using
CMYK color info. Since this translation can cause information loss you should specify colors using the
color info class that matches the document’s color space.
rounded rectangle
A class used to create a rectangular path with rounded corners in an Illustrator document. This object is
available only in the context of a make command, which creates an instance of the path item class. This
special class allows you to quickly create complex path items. Properties associated with path items, such
as fill color and note, can also be specified at the time of creation.
If you do not specify any properties when making a new rounded rectangle, default values are used.
screen properties
Contains screen information.
separation screen
Represents a color-separation screen.
spot, spots
A custom color definition, or list of definitions, contained in a document.
If no properties are specified when creating a new spot, default properties will be provided. If specifying
the color, however, you must use the same color space as the document, either CMYK or RGB; otherwise,
an error will result. When created, the spot is added to the end of the swatches list in the Swatches palette.
container object reference Read-only. A reference to the document that contains this
spot color.
default type type class Read-only. Default type for the spot. Always returns
reference.
star
A class used to create a star-shaped path in an Illustrator document. This object is available only in the
context of a make command, which creates an instance of the path item class. This special class allows you
to quickly create complex path items. Properties associated with path items, such as fill color and
note, can also be specified at the time of creation.
Create a star
-- Make a 16-pointed star
tell application "Adobe Illustrator"
make new star in document 1 with properties ¬
{center point:{200.0, 500.0}, inner radius:70, radius:100, point count:16} ¬
end tell
CHAPTER 1: AppleScript Objects story, stories 185
story, stories
A contiguous block of text. A story can contain one or more text frames; if more—the multiple text frames
are threaded to form a single story.
Elements Refer to by
character numeric index, range of elements, before/after another element, satisfying a test
insertion point numeric index, range of elements, before/after another element, satisfying a test
line numeric index, range of elements, before/after another element, satisfying a test
paragraph numeric index, range of elements, before/after another element, satisfying a test
text numeric index, range of elements, before/after another element, satisfying a test
text frame name, numeric index, range of elements, before/after another element, satisfying a
test
word numeric index, range of elements, before/after another element, satisfying a test
Using stories
-- Story
-- Make a new document and two text frames
-- Set the previous frame of the second text frame to text frame 1
-- Add a story to text frame 1, long enough to overflow to text frame 2
-- Count the number of stories
-- Add a new text frame
-- Count the number of stories
This class is used to define a record containing properties that specify options when exporting a document
as a SVG file. SVG export options can only be supplied in conjunction with the export command. It is not
possible to get or create an SVG export options object.
document encoding Valid values: How the text should be encoded in the
ASCII document. Default: ASCII
UTF8
UTF16
DTD Valid values: The DTD version to which the exported file
SVG 1.0 conforms. Default: SVG 1.1
SVG 1.1
SVG Basic 1.1
SVG Tiny 1.1
SVG Tiny 1.1 Plus
Export to SVG
This handler saves all files in a folder as SVG files with linked raster imaged embedded in the exported files.
The class property is specified in the record to ensure that Illustrator can determine the save option class.
-- Opens files from a predefined source folder in Illustrator
-- then exports them to a predefined destination folder in the chosen format
-- fileList is a list of file names in the source folder
-- filePath is the full path to the source folder
-- destFolder is an alias to a folder where the files are to be saved
swatch, swatches
A color swatch or list of swatches contained in a document. The swatches correspond to the swatch
palette in the Illustrator user interface. Additional swatches can be created either manually by a user or by
a script. The swatch can hold all types of color data (such as pattern, gradient, CMYK, RGB, gray, or spot).
Create a swatch
-- Make a new swatch
tell application "Adobe Illustrator"
set swatchCount to count of swatches in document 1
make new swatch in document 1 with properties ¬
{name:"My Swatch", color:{red:175.0, green:50.0, blue:0.0}}
end tell
CHAPTER 1: AppleScript Objects swatchgroup, swatchgroups 191
swatchgroup, swatchgroups
A group of swatches.
symbol, symbols
A symbol or list of symbols. A symbol is an art item that is stored in the Symbols palette, and can be reused
one or more times in the document without duplicating the art data. Symbols are contained in
documents.
Using symbols
-- Symbol Items
-- Make a new document
-- Add rectangles, apply different graphic style to each
-- Add delay of at least a second (allow UI to catch up to scripting plug-in)
-- Make a new symbol for each page item, use the page item as the source art
decimal character Unicode text The character to use for decimal tab stops.
leader Unicode text The leader dot.
position real The position of the tab stop expressed in points. Default: 0.0
tag, tags
A tag or list of tags associated with a specific page item. Tags allows you to assign an unlimited number of
key-value pairs to any page item in a document.
Get tags
-- Creates then gets tags for the first page item in the document
tell application "Adobe Illustrator"
make new document
set newItem to make rectangle in document 1 with properties {name:"rectPath"}
set myPosition to position of newItem
set myBoundsString to ((item 1 of myPosition) & "," & (item 2 of myPosition) as
string) & ","
set myBoundsString to myBoundsString & ((width of newItem) & "," & (height of
newItem) as string)
set myTag to (make new tag at newItem)
set name of myTag to "MyNewTag"
set value of myTag to myBoundsString
set URL of newItem to "http://www.adobe.com/"
set tempProp to properties of myTag
set myTagPropName to name of tempProp
end tell
CHAPTER 1: AppleScript Objects text 200
text
Any text in the contents of a text frame. Text can be accessed using the character, insertion point,
word, line, paragraph, and text classes. All text is contained within text frames.
Elements Refer to by
character style name, numeric index, range of elements, before/after another element, satisfying a
test
character numeric index, range of elements, before/after another element, satisfying a test
insertion point numeric index, range of elements, before/after another element, satisfying a test
line numeric index, range of elements, before/after another element, satisfying a test
paragraph style name, numeric index, range of elements, before/after another element, satisfying a
test
paragraph numeric index, range of elements, before/after another element, satisfying a test
text numeric index, range of elements, before/after another element, satisfying a test
word numeric index, range of elements, before/after another element, satisfying a test
class type class Read-only. The object’s class, which is text font.
default type class Read-only. The default type for the object. Always returns reference.
type
When you create a text frame, you also create a story object (see story, stories); however, threading text
frames combines the frames into a single story object. To thread frames, use the next frame or previous
frame property.
Element Refer to by
character index, before/after, range, test
insertion point index, before/after, range, test
line index, before/after, range, test
paragraph index, before/after, range, test
text index, before/after, range
word index, before/after, range, test
column gutter real The column gutter in the text frame (area text only).
content variable anything The content variable to which this text frame is bound.
previous frame text frame The linked text frame preceding this one.
properties record All properties of this object returned as a record.
row count integer The row count in the text frame (area text only).
row gutter real The row gutter in the text frame (area text only).
selection object Read-only. The selected text.
reference
spacing real The amount of spacing.
start T value real The start position of text along a path, as a value relative to the
path
text path list of path Read-only. The path item associated with the text frame.
point info
NOTE: Valid only when kind is area text or path text.
text range Unicode text Read-only. The text in the text frame.
CHAPTER 1: AppleScript Objects text frame, text frames 205
Element Refer to by
path point index, range of elements, before/after another element, satisfying a test
position list The position (in points) of the top left corner of the item in
the format {x, y}. Does not include stroke weight.
resolution real The resolution of the path in dots per inch.
selected path list of object Read-only. All selected path points in the path.
points references
stroke cap Valid values: The type of line capping.
butted
rounded
projecting
stroke color color info The stroke color for the path.
stroke dash real The default distance into the dash pattern at which the
offset pattern should be started
stroke dashes list of real numbers The lengths for dashes and gaps in dashed lines, starting
with the first dash length, followed by the first gap length,
and so on. Set to an empty list, {}, for a solid line.
stroke joi Valid values: Type of join for the path.
mitered
rounded
beveled
stroke miter real When a default stroke join is set to mitered, this property
limit specifies when the join will be converted to beveled
(squared-off ) by default. The default miter limit of 4 means
that when the length of the point reaches four times the
stroke weight, the join switches from a miter join to a bevel
join. Values: 1 to 500. 1 specifies a bevel join.
stroke boolean If true, the art beneath the stroked object should be
overprint overprinted.
stroke width real Width of stroke.
CHAPTER 1: AppleScript Objects text path item, text path items 209
This class contains properties that specify options to be used when exporting a document as a TIFF file.
TIFF export options can only be supplied in conjunction with the export command. It is not possible to
get or create a TIFF export options object.
byte order Valid values: The byte order to use in the new file.
IBM PC
MACINTOSH
imagecolorspace Valid values: The color space of the exported file. Default: RGB
Gray
RGB
CMYK
tracingobject, tracings
Associates source raster art item with a vector-art plugin group created by tracing. Scripts can initiate
tracing using the trace placed command for a placed item or raster item. The resulting plugin item
object represents the vector art group, and has this object in its tracing property.
A script can force the tracing operation by calling the application’s redraw command. The operation is
asynchronous, so a script should call redraw after creating the tracingobject, but before accessing its
properties or expanding the tracing to convert it to an art item group.
The read-only properties that describe the tracing result have valid values only after the first tracing
operation completes. A value of 0 indicates that the operation has not yet been completed.
live paint boolean If true, result is LivePaint art. If false, it is classic art.
output
NOTE: A script should set this value only in preparation
for a subsequent expand operation. Leaving a tracing
on the artboard when this property is true can lead to
unexpected application behavior.
maximum integer The maximum number of colors allowed for automatic
colors palette generation. Used only if tracing mode is color
or grayscale. Range: 2 to 256
maximum real The maximum stroke weight, when strokes is true.
stroke Range: 0.01 to 100.0
weight
minimum integer The smallest feature, in square pixels, that is traced. For
area example, if it is 4, a feature of 2 pixels wide by 2 pixels
high is traced.
minimum real The minimum length in pixels of features in the original
stroke image that can be stroked, when strokes is true.
length Smaller features are omitted. Range: 0.0 to 200.0
Default: 20.0
output boolean If true, named colors (swatches) are generated for
swatches each new color created by the tracing result. Used only
if tracing mode is color or grayscale.
CHAPTER 1: AppleScript Objects tracing options, multiple tracing options 213
path real The distance between the traced shape and the
fitting original pixel shape. Lower values create a tighter path
fitting. Higher values create a looser path fitting.
Range: 0.0 to 10.0
preprocess real The amount of blur used during preprocessing.
blur Blurring helps reduce small artifacts and smooth
jagged edges in the tracing result. Range: 0.0 to 2.0
preset string Read-only. The name of a preset file containing these
options.
properties record All properties of this object returned as a record.
resample boolean If true, resample when tracing. (This setting is not
captured in a preset file.)
view raster Valid values: The view for previews of the raster image. (This setting
view adjusted image is not captured in a preset file.)
view no image
view original image
view transparent image
view vector Valid values: The view for previews of the vector result. (This setting
view no tracing result is not captured in a preset file.)
view outlines
view outlines tracing
view tracing result
CHAPTER 1: AppleScript Objects tracing options, multiple tracing options 214
variable, variables
A document-level variable that can be imported or exported.
A variable is a dynamic object used to create data-driven graphics. For an example, see dataset, datasets.
Variables are accessed in Illustrator through the Variables palette.
Element Refer to by
page item name, numeric index, range of elements, before/after another element, satisfying a test
index integer Read-only. The index of this variable in the art item.
kind Valid values: The kind of variable.
graph
image
textual
unknown
visibility
view, views
A document view or list of views in an Illustrator document. The view object represents a window view
onto a document. Scripts cannot create new views, but can modify some properties of existing views,
including the center point, screen mode, and zoom.
bounds rect Read-only. The bounding rectangle of this view relative to the
current document’s bounds
center point fixed point The center point of this view relative to the current document’s
bounds
class type class Read-only. The object’s class, which is view.
rotateAngle real The rotation angle of this view.
container object reference Read-only. A reference to the document that contains this view.
default type type class Read-only. The default type for the view object. Always returns
reference.
zoom real The zoom factor of this view, where 1.0 is 100%.
Center a view
-- Center the view on the first selected object
tell application "Adobe Illustrator"
set selectedItems to the selection
if selectedItems is not {} then
set firstObject to item 1 of selectedItems
set newPosition to position of firstObject
set center point of view 1 of document 1 to newPosition
end if
end tell
CHAPTER 1: AppleScript Objects view, views 217
When you export a document, the appropriate file extension is appended automatically. You should not
include any file extension in the file specification.
word
A string of text in a text frame that is separated by whitespace. A document’s text can be accessed using
the character, insertion point, word, line, paragraph, and text classes. All text is contained within
text frames.
Elements Refer to by
character name, numeric index, range of elements, before/after another element, satisfying a test
style
character numeric index, range of elements, before/after another element, satisfying a test
insertion numeric index, range of elements, before/after another element, satisfying a test
point
line numeric index, range of elements, before/after another element, satisfying a test
paragraph name, numeric index, range of elements, before/after another element, satisfying a test
style
paragraph name, numeric index, range of elements, before/after another element, satisfying a test
text numeric index, range of elements, before/after another element, satisfying a test
word name, numeric index, range of elements, before/after another element, satisfying a test
baseline shift real The amount of shift (in points) of the text
baseline.
best type type class Read-only. The best type for the object’s
value.
capitalization Valid values: Specifies whether the text is normal, all
all caps uppercase, all small caps, or a mix of small
all small caps caps and lowercase.
normal
small caps
default type type class Read-only. The default type for the
object’s value.
discretionary boolean If true, use the discretionary ligature.
ligature
CHAPTER 1: AppleScript Objects word 221
baseline shift real The amount of shift (in points) of the text
baseline.
best type type class Read-only. The best type for the object’s
value.
capitalization Valid values: Specifies whether the text is normal, all
all caps uppercase, all small caps, or a mix of small
all small caps caps and lowercase.
normal
small caps
default type type class Read-only. The default type for the
object’s value.
discretionary boolean If true, use the discretionary ligature.
ligature
CHAPTER 1: AppleScript Objects word 222
This example demonstrates how to use the matching abilities of the whose clause in conjunction with
word properties to modify words that match a specific string.
-- Change the color of every occurrence of a specific
-- word in all text frames
This chapter provides a complete reference for the commands in the Illustrator AppleScript dictionary. The
commands are presented alphabetically.
The commands supported by each object, with links to the detailed descriptions here, are listed in
Chapter 1, “AppleScript Objects.”
Overview
This chapter describes the commands in the Illustrator AppleScript dictionary, as well as some of the
important standard AppleScript commands. The AppleScript dictionary itself shows only that the
command returns an object, or that the command takes an object reference as a parameter; it does not
show the specific objects that can respond to a particular command. Not all Illustrator objects can respond
to all commands; this reference details which objects respond to which commands, and what type of
object each command returns (if any).
227
CHAPTER 2: AppleScript Commands activate 228
activate
Makes an application active; that is, makes Illustrator the front-most application.
Notes Illustrator must be the frontmost application when executing any command that deals with the clipboard.
Use this command to ensure this. See the clipboard commands for examples.
CHAPTER 2: AppleScript Commands add document 229
add document
Creates a new document from a preset template.
add spot
Adds a spot swatch to the swatch group.
add swatch
Adds a swatch to the swatch group.
apply
Applies a brush or graphic style to one or more page items.
to anything The page item or items to which to apply compound path item
abrush or graphic style. group item
mesh item
non native item
page item
path item
placed item
plugin item
raster item
text frame
Notes Use apply to affect one or more page items by applying an existing brush or graphic style. Brushes and
graphic styles can be created in the user interface, but not from a script.
arrange
The style in which to arrange multiple documents in the main window.
cascade
horizontal tile
vertical tile
float all
consolidate all
CHAPTER 2: AppleScript Commands bring in perspective 236
bring in perspective
Places art object(s) in a perspective grid at a specified position and grid plane.
capture
Captures the current document window to the target TIFF image file.
Objects
Parameters What it is supported Returns
to file specification The TIFF file to which the captured image should document nothing
be written.
size point The size to make the window before capture.
CHAPTER 2: AppleScript Commands change case 238
change case
Changes the capitalization of the selected text.
Objects
Parameters What it is supported Returns
text The text object or objects to be operated upon. text nothing
to lower case/ The type of case.
sentence case/
title case/
upper case
CHAPTER 2: AppleScript Commands close 239
close
Closes a document.
Objects
Parameters What it is supported Returns
document The document to close. document nothing
[saving yes/no/ask] Whether to save the document before closing.
Close a document
-- Close the first document and prompt the user with a "Save as" dialog
tell application "Adobe Illustrator"
activate
close document 1 saving ask
end tell
CHAPTER 2: AppleScript Commands colorize 240
colorize
Colorizes a raster item.
concatenate matrix
Concatenates two transformation matrices to form a single resulting matrix.
Concatenate matrices
-- This script concatenates 2 matrices
tell application "Adobe Illustrator"
set someMatrix to get identity matrix
set anotherMatrix to get rotation matrix angle 30.0
set newMatrix to concatenate matrix someMatrix with anotherMatrix
end tell
CHAPTER 2: AppleScript Commands concatenate rotation matrix 242
convert
Converts the legacy text item to a text frame and deletes the original legacy text item.
convert coordinate
Converts the coordinates of a single point from one coordinate system to another. Returns the modified
coordinate list.
Objects
Parameters What it is supported Returns
source color space image The source color space. application array of
color space ColorComponents
source color color The color to convert, a color sample An array of color
components object. The first location should components(e.g.
contain alpha if source has alpha R,G and B value)
is true. which constitute
destination color space The destination color space. The the color. First
image color space first location should contain alpha if location of
dest has alpha is true. returned array will
contain alpha
color convert purpose The purpose of conversion. Valid value if
color conversion purpose values: destination-has-al
default purpose pha is true.
dummy purpose option
export purpose
preview purpose
convert to paths
Converts the specified text to path items.
copy
Copies the selection in the current document to the clipboard.
Notes Commands that manipulate the clipboard (cut, copy, and paste) require that Illustrator be the frontmost
application during these operations. Use activate to bring Illustrator to the front before executing the
copy command. No error is returned if there is no selection to copy. If the application is not frontmost, an
error is returned.
count
Counts the elements of a specified type contained in a specified object.
Notes With the optional each/every term, use the singular form for the object type to be counted; for example,
brush rather than brushes. Otherwise, you can use the singular or plural form.
cut
Cuts the current selection from the current document and places it in the clipboard.
Notes Commands that manipulate the clipboard (cut, copy, and paste) require that Illustrator be the frontmost
application. Use activate to bring Illustrator to the front before executing the cut command. No error is
returned if there is no selection to cut. If the application is not frontmost, an error is returned.
delete
Removes one or more elements from a container, or deletes one or more objects.
Delete a layer
-- This script deletes the second layer in the document
tell application "Adobe Illustrator"
if (count layers of document 1) > 1 then
delete layer 2 of document 1
end if
end tell
CHAPTER 2: AppleScript Commands delete preference 255
delete preference
Removes the application preference key. See “Preference accessor guidelines” on page 78.
delete workspace
Removes the given workspace.
deselect
Deselects a text range.
display
Displays the dynamic data that has been captured in a dataset object.
.
do javascript
Executes a JavaScript script and returns the result of execution.
do script
Plays an action from the Actions palette.
Objects
Parameters What it is supported Returns
Unicode text The name of the action to play. Case-sensitive. N/A nothing
from Unicode text The name of the Action Set containing the action.
Case-sensitive.
[dialogs boolean] If true, dialog boxes should be associated with the
action presented to the user. Default: true
Notes If the action is selected in the Actions palette in the Illustrator user interface, this command returns an
error.
Execute an action
-- This script executes an action in the default set without displaying any dialogs
tell application "Adobe Illustrator"
do script "Opacity 60 (selection)" from "Default Actions" without dialogs
end tell
CHAPTER 2: AppleScript Commands duplicate 261
duplicate
Duplicates an object or objects.
Objects
Parameters What it is supported Returns
object reference The object or objects to duplicate all objects except: object
reference or
[to location reference] The location for the new object or application list (of object
objects mesh item
references)
plugin items
[with properties record] New values for specified properties
of the new object or objects
Notes You can duplicate page items from one document to another. This is equivalent to setting the selection,
performing a cut or copy, bringing another document to the front, and then pasting. When duplicating
objects from one document to another, you must specify the location reference.
equal matrices
Compares two matrices for equality.
Compare matrices
-- This script compares 2 matrices and beeps if they are equal
tell application "Adobe Illustrator"
set someMatrix to get identity matrix
set anotherMatrix to get identity matrix
if (equal matrices someMatrix with anotherMatrix) then beep
end tell
CHAPTER 2: AppleScript Commands embed 263
embed
Embeds linked art in a document. Applied to a placed item, it converts the art to art item objects as
needed and deletes the placed item object.
exists
Determines whether an object exists.
expand tracing
Converts the vector art associated with a tracingobject into a new group item. The new group item
object replaces the plugin item object in the document. Deletes this object and its associated plugin
item object. Any group-level attributes that were applied to the plugin item are applied to the top level of
the new group item.
export
Exports the specified document to a specified file type.
Objects
Parameters What it is supported Returns
object reference The document to export. document nothing
to file The file to export to, specified as a string containing
specification the full file path or an alias.
as JPEG/Photoshop/ The file type to which to export the document.
SVG/PNG8/PNG24/
GIF/AutoCAD/TIFF
[with options] The export options for the specified file type.
object reference
Objects
Parameters What it is supported Returns
document The document object or objects to be operated on. document nothing
to file specification The file to export to, specified as a string containing
the full file path or an alias.
CHAPTER 2: AppleScript Commands export perspective grid preset 268
Objects
Parameters What it is supported Returns
document The document object or objects to be operated document nothing
upon.
to file specification The file to export to.
CHAPTER 2: AppleScript Commands export print preset 269
Objects
Parameters What it is supported Returns
document The document object or objects to be operated on. document nothing
to file specification The file to export to, specified as a string containing
the full file path or an alias.
CHAPTER 2: AppleScript Commands export variables 270
export variables
Saves datasets containing variables and their associated dynamic data into an XML library.
Objects
Parameters What it is supported Returns
document The document object or objects to be operated on. document nothing
to file specification The file to export to, specified as a string containing
the full file path or an alias.
CHAPTER 2: AppleScript Commands fit artboard to selected art 271
Objects
Parameters What it is supported Returns
document The document object or objects to be operated on. document boolean
get
Gets data from an object.
Notes This standard AppleScript command is included because it illustrates AppleScript’s ability to coerce values
from one value type to another. You do not need to use get to assign values to variables.
-- This script gets the contents of a text frame both as a string and as a reference
tell application "Adobe Illustrator"
set textString to contents of text frame 1 of document 1
set textRef to text of text frame 1 of document 1 as reference
end tell
CHAPTER 2: AppleScript Commands get all swatches 273
Notes The identity matrix is a transformation matrix that causes no transformation. Use it to get a base matrix to
use with the matrix concatenation commands.
Notes Requires a value in degrees. 30 rotates the object 30 degrees counterclockwise; -30 rotates the object 30
degrees clockwise.
Objects
Parameters What it is supported Returns
[horizontal scale real] The horizontal scaling factor as a percentage. matrix matrix
Default is 100.0, which is 100%
[vertical scale real] The vertical scaling factor.
Default is 100.0, which is 100%
Requires a value in percentage. 60 scales the object to 60% of its original size; 200 doubles the objects
bounds.
PresentationMode
CHAPTER 2: AppleScript Commands get scriptable help group 286
get selected
Gets the selected swatches in a document.
Requires a value in points. {100,200} moves the object 100 pt. to the right and 200 pt. up; a minus (-) before
each number moves the object left and down.
Objects
Parameters What it is supported Returns
document The document object or objects to be operated document boolean
upon.
CHAPTER 2: AppleScript Commands image capture 292
image capture
Captures the artwork content within the clipping boundaries in this document as a raster image, and
writes the image data to a specified file.
Objects
Parameters What it is supported Returns
to file specification The file to which the captured image should be document nothing
written.
[inside rect] The rectangular region of the artwork for image
capture. If omitted, captures the entire artwork.
[with options image The object describing the image-capture options.
capture options]
CHAPTER 2: AppleScript Commands import character styles 293
Objects
Parameters What it is supported Returns
document The document object or objects to be document nothing
operated on.
print preset Unicode text The name of the print preset to
import.
from file specification The file to import from, specified as a
string containing the full file path or
an alias.
CHAPTER 2: AppleScript Commands import variables 298
import variables
Loads a library from a file that contains datasets, variables, and the associated dynamic data. The imported
data overwrites any existing variables and datasets.
Objects
Parameters What it is supported Returns
document The document object or objects into which to document nothing
import variables
from file specification The file from which to import variables,
specified as a string containing the full file
path or an alias.
CHAPTER 2: AppleScript Commands invert matrix 299
invert matrix
Returns an inverted matrix.
Notes A singular matrix cannot be inverted. Use the singular matrix command to test if a matrix is singular.
Invert a matrix
-- This script gets the inverse matrix of a 50% vertical scale matrix
-- When applied, the inverse matrix scales the object 200% vertically
tell application "Adobe Illustrator"
set transformMatrix to get scale matrix vertical scale 50.0
set transformMatrix to invert matrix transformMatrix
transform page item 1 of document 1 using transformMatrix
end tell
CHAPTER 2: AppleScript Commands is ruler visible 300
is ruler visible
If true, the ruler is visible.
launch
Launches Illustrator.
load preset
Loads a set of preset tracing options from a file into a tracing options object.
make
Creates a new object and returns a reference to newly created object. To place new art in a document, use
this command to create a placed item, then use the embed command on the resulting placed item
object to convert it to embedded art items.
Objects
Parameters What it is supported Returns
new type class The class of object to create. The term all objects except: object
new is optional. reference
application
at location reference Location at which to insert new object. mesh item
plugin item
[with properties record] Any property of the object you wish to
set at creation.
[with data anything] Any data needed for creation that is
not a property.
Create layers
merge
Merges this style into the current style(s) of the specified items.
move
Moves one or more objects to a new location; returns references to the moved object or objects at the new
location.
Move layers
-- This script moves the bottommost layer to after the first layer
tell application "Adobe Illustrator"
tell document 1 to move last layer to after first layer
end tell
CHAPTER 2: AppleScript Commands open 308
open
Opens one or more specified documents.
Objects
Parameters What it is supported Returns
file specification The file to be opened. N/A nothing
[forcing RGB/CMYK] Pre-Illustrator 9 files only.
paste
Pastes the clipboard contents into the current layer of the current document.
Notes Commands that manipulate the clipboard (cut, copy, and paste) require that Illustrator be the frontmost
application. Use activate to bring Illustrator to the front before executing the paste command. No error
is returned if there is no selection to paste. If the application is not frontmost, an error is returned.
print
Prints one or more documents or files.
Print a document
-- Print the current document without displaying a dialog
tell application "Adobe Illustrator"
print document 1 without dialog
end tell
end repeat
set jobOptions to {class:job options, designation:all layers, reverse pages:true} ¬
set printOptions to ¬
¬
{class:print options, job settings:jobOptions, color management
settings:colorOptions, coordinate settings:coordinateOptions, flattener
settings:flatteningOptions} ¬
quit
Forces Illustrator to quit.
Quit Illustrator
-- Quit Illustrator after clearing the clipboard and closing documents
tell application "Adobe Illustrator"
activate
set the clipboard to {}
close every document saving no
quit
end tell
CHAPTER 2: AppleScript Commands rasterize 312
rasterize
Rasterizes the source art(s) within the specified clip bounds. The source art(s) is disposed of as a result of
the rasterization.
Objects
Parameters What it is supported Returns
SourceArt variant The page item(s) to be rasterized. document page item
rearrange artboards
Rearranges artboards in a document.
Objects
Parameters What it is supported Returns
document The document object or objects to document boolean
operate on.
[artboardLayout column/grid by The layout style to use. Default is
column/grid by row/rl grid by grid by row.
row/rl row/row]
redo
Redoes the most recently undone transaction.
redraw
Forces Illustrator to redraw its window or windows.
Redraw
-- This script redraws all windows in Illustrator
tell application "Adobe Illustrator" to redraw
CHAPTER 2: AppleScript Commands release tracing 316
release tracing
Reverts vector artwork in the document that was created by tracing to the original source raster art, and
removes the traced vector art. Returns the original object used to create the tracing, and deletes the
tracingobject object and its associated plugin item object.
relink
Relinks placed art in a document with the file that defines the content. Applied to a placed item, it
associates the placed item object with the specified file.
Relink
-- This script relinks all placed art in the current document to a specific image file
tell application "Adobe Illustrator"
activate
reset workspace
Resets the current workspace.
rotate
Rotates one or more page items counterclockwise by a specified rotation angle.
Notes The rotate command provides many variations when used with the about parameter. Experiment with
different choices for about to see what the results are for each setting.
save
Saves an Illustrator document. Returns a reference to the saved document.
Objects
Parameters What it is supported Returns
document The document to save. document object
reference
[in file specification] The file to save to, specified as a string
containing the full file path or an alias.
[with options anything] The save options for the specified file type.
This example shows to batch process folders of Illustrator documents, saving each as a PDF file with
specific settings.
-- Save each Illustrator file as a PDF file.
-- fileList is a list of aliases to Illustrator files
-- filePath is the path to the folder containing the files
-- destFolder is an alias to a folder where the PDF files are to be saved
save workspace
Saves a new workspace.
scale
Scales one or more page items by the specified horizontal and vertical amounts.
Notes The scale command provides many variations when used in conjunction with the about parameter.
Experiment with different choices for the about parameter to see what the results are for each setting.
select
Selects the text range.
Objects
Parameters What it is supported Returns
text The text object or objects to select. text nothing
[extending selection If true, the text range is added to the document’s
boolean] existing text selection. Default: false
CHAPTER 2: AppleScript Commands select objects on active artboard 324
Objects
Parameters What it is supported Returns
document The document object or objects to be operated document boolean
upon.
perspective preset text Name of a perspective grid preset.
CHAPTER 2: AppleScript Commands set 326
set
Changes the value of a variable or an object’s property or data. This is a standard AppleScript command
used to assign values to variables and object properties.
Objects
Parameters What it is supported Returns
property or variable The object property or script variable to modify. any property nothing
or variable
to anything Any valid value.
Set a property
-- Set the zoom property of the frontmost view window to 100%
tell application "Adobe Illustrator"
set zoom of view 1 of document 1 to 1.0
end tell
CHAPTER 2: AppleScript Commands set boolean preference 327
Objects
Parameters What it is supported Returns
set grid the grid repeat item object or objects to be grid repeat nothing
item, grid
configuration operated upon
grid repeat repeat items
item, grid
repeat items
write as library
Writes the document to a file as a library of specified type.
Objects
Parameters What it is supported Returns
set grid the radial repeat item object or objects to radial repeat nothing
configuration item, radial
be operated upon repeat items
radial repeat
item, radial
repeat items
Objects
Parameters What it is supported Returns
set grid the symmetry repeat item object or objects symmetry repeat nothing
configuration item, symmetry
to be operated upon repeat items
symmetry
repeat item,
symmetry
repeat items
Objects
Parameters What it is supported Returns
document The document object or objects to be document boolean
operated upon.
CHAPTER 2: AppleScript Commands show presets 337
show presets
Returns presets from a file as a list of Unicode text items.
Objects
Parameters What it is supported Returns
from file The file to import from, specified as a string N/A list (of Unicode
specification containing the full file path or an alias. text)
CHAPTER 2: AppleScript Commands singular matrix 338
singular matrix
Tests an existing matrix to see if it is singular. A singular matrix cannot be inverted.
Invert a matrix
-- This script gets an identity matrix and then
-- test to see if it can be inverted (if not singular)
-- If it can, then it inverts it
tell application "Adobe Illustrator"
set someMatrix to get identity matrix
if (not (singular matrix someMatrix)) then
set someMatrix to invert matrix someMatrix
set testResult to true
else
set testResult to false
end if
end tell
CHAPTER 2: AppleScript Commands store preset 339
store preset
Saves a set of preset tracing options from a tracing options object. For an existing preset, overwrites an
unlocked preset and returns true. Returns false if the preset is locked.
switch workspace
Switches to the given workspace.
trace placed
Converts the raster art for the art item to vector art, using default options. Reorders the placed art into the
source art of a plugin group, and converts it into a group of filled and/or stroked paths that resemble the
original image.
Creates and returns a plugin item object that references a traceobject object.
trace raster
Converts the raster art for the art item to vector art, using default options. Reorders the raster art into the
source art of a plugin group, and converts it into a group of filled and/or stroked paths that resemble the
original image.
Creates and returns a plugin item object that references a traceobject object.
transform
Transform one or more page items by a specified matrix.
Notes This command can be used to generate any combination of transformations contained in a matrix, making
it possible to skew objects among other modifications. The command provides many variations when
used with the about parameter. Experiment with different choices for about to see what the results are for
each setting.
Transform an object
-- This script skews an object 45 degrees to the right horizontally
-- by generating a rotation matrix and setting the appropriate matrix values
tell application "Adobe Illustrator"
set baseMatrix to get rotation matrix angle 45.0
set mvalue_b of baseMatrix to 0
set startGeoBounds to geometric bounds of page item 1 of document 1
transform page item 1 of document 1 using baseMatrix
end tell
CHAPTER 2: AppleScript Commands translate 344
translate
Moves one or more page items from their existing position in a document to a new position defined by
relative coordinates.
Notes Use translate to move objects relatively from their existing position. Set the position property of an
object to move the object to absolute coordinates.
undo
Undoes the most recent transaction.
update
Reapplies the dynamic data of the active dataset to the artboard.