2
cs
®
Illustrator
®
JavaScript Reference
Adobe
bbc
© 2005 Adobe Systems Incorporated. All rights reserved.
Æ
Adobe
Illustrator® CS2 JavaScript Reference for Windows® and Mac OS®.
NOTICE: All information contained herein is the property of Adobe Systems Incorporated. No part of this publication (whether in hardcopy or
electronic form) may be reproduced or transmitted, in any form or by any means, electronic, mechanical, photocopying, recording, or
otherwise, without the prior written consent of Adobe Systems Incorporated. The software described in this document is furnished under
license and may only be used or copied in accordance with the terms of such license.
This publication and the information herein is furnished AS IS, is subject to change without notice, and should not be construed as a
commitment by Adobe Systems Incorporated. Adobe Systems Incorporated assumes no responsibility or liability for any errors or
inaccuracies, makes no warranty of any kind (express, implied, or statutory) with respect to this publication, and expressly disclaims any and
all warranties of merchantability, fitness for particular purposes, and noninfringement of third party rights.
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, and Illustrator are either registered trademarks or trademarks of Adobe Systems Incorporated in the United
States and/or other countries.
Apple, Mac, Macintosh, and Mac OS are trademarks of Apple Computer, Inc., registered in the United States and other countries. Microsoft,
and Windows are either registered trademarks or trademarks of Microsoft Corporation 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.
All other trademarks are the property of their respective owners.
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 Systems 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 Systems Incorporated. Adobe Systems Incorporated assumes no responsibility or liability for any errors or
inaccuracies that may appear in the informational content contained in this guide.
Adobe Systems Incorporated, 345 Park Avenue, San Jose, California 95110, USA.
Contents
1 Introduction ...............................................................................................................................47
What is scripting? .........................................................................................................................................................................47
Why use scripting?.................................................................................................................................................................48
What about actions? .............................................................................................................................................................48
Script Support in Adobe Illustrator CS2 ...............................................................................................................................49
JavaScript support .................................................................................................................................................................49
Executing scripts ....................................................................................................................................................................49
Installing scripts ...............................................................................................................................................................49
Executing other scripts..................................................................................................................................................50
Startup scripts .........................................................................................................................................................................50
Changes Since Earlier Versions................................................................................................................................................50
2 Scripting Basics.......................................................................................................................... 52
Object model concepts..............................................................................................................................................................52
Object classes and containers ...........................................................................................................................................53
Object inheritance .................................................................................................................................................................53
Object elements or collections .........................................................................................................................................53
Object references...................................................................................................................................................................53
Scripting concepts .......................................................................................................................................................................54
Comments ................................................................................................................................................................................54
Long script lines......................................................................................................................................................................54
Case sensitivity........................................................................................................................................................................54
Value types ...............................................................................................................................................................................54
Variables ....................................................................................................................................................................................55
Declaring variables and assigning values ...............................................................................................................55
Variable naming ...............................................................................................................................................................56
Operators ..................................................................................................................................................................................56
Functions...................................................................................................................................................................................57
Conditional statements .......................................................................................................................................................57
Control structures ..................................................................................................................................................................57
Including Other Script Files ................................................................................................................................................58
Testing and troubleshooting ...................................................................................................................................................58
About error handling............................................................................................................................................................59
JavaScript Resources...................................................................................................................................................................59
3 Scripting Illustrator ................................................................................................................... 60
The Illustrator object model .....................................................................................................................................................60
Referencing and Creating Objects in JavaScript.........................................................................................................61
Working with the Selection Object .................................................................................................................................62
Working with paths ...............................................................................................................................................................62
Working with color ................................................................................................................................................................63
Working with symbols and symbol items.....................................................................................................................63
Working with Methods...............................................................................................................................................................63
Working with Text and Printing ..............................................................................................................................................64
Content of a Text Range......................................................................................................................................................65
Character Style, Character Attributes, Local Character Attributes .......................................................................65
3
Adobe Illustrator CS2
JavaScript Scripting Reference 4
Printing Illustrator Documents..........................................................................................................................................65
Measurement units......................................................................................................................................................................66
Em Space Units .......................................................................................................................................................................67
Page item positioning and dimensions .........................................................................................................................67
4 Using File and Folder Objects ................................................................................................... 69
Overview .........................................................................................................................................................................................69
Specifying Paths............................................................................................................................................................................69
Absolute and relative path names...................................................................................................................................69
Character interpretation in paths.....................................................................................................................................70
The home directory...............................................................................................................................................................70
Volume and drive names ....................................................................................................................................................71
Mac OS volumes...............................................................................................................................................................71
Windows drives ................................................................................................................................................................71
Aliases.........................................................................................................................................................................................72
Portability issues.....................................................................................................................................................................72
Unicode I/O ....................................................................................................................................................................................72
File Error Handling ......................................................................................................................................................................73
5 JavaScript Object Reference ..................................................................................................... 74
Application .....................................................................................................................................................................................75
Application properties .........................................................................................................................................................75
activeDocument.....................................................................................................................................................................75
browserAvailable ...................................................................................................................................................................75
documents ...............................................................................................................................................................................75
flattenerPresetsList................................................................................................................................................................75
freeMemory..............................................................................................................................................................................75
name...........................................................................................................................................................................................75
path.............................................................................................................................................................................................75
PDFPresetsList.........................................................................................................................................................................75
PPDFileList ................................................................................................................................................................................75
preferences...............................................................................................................................................................................75
printerList..................................................................................................................................................................................75
printPresetsList .......................................................................................................................................................................75
scriptingVersion......................................................................................................................................................................75
selection ....................................................................................................................................................................................75
textFonts ...................................................................................................................................................................................75
tracingPresetList.....................................................................................................................................................................75
typename..................................................................................................................................................................................75
userInteractionLevel .............................................................................................................................................................75
version........................................................................................................................................................................................76
visible..........................................................................................................................................................................................76
Application methods ............................................................................................................................................................76
beep............................................................................................................................................................................................76
concatenateMatrix.................................................................................................................................................................76
concatenateRotationMatrix ...............................................................................................................................................76
concatenateScaleMatrix ......................................................................................................................................................76
concatenateTranslationMatrix ..........................................................................................................................................76
getIdentityMatrix ...................................................................................................................................................................76
getRotationMatrix..................................................................................................................................................................76
getScaleMatrix ........................................................................................................................................................................76
getTranslationMatrix ............................................................................................................................................................76
Adobe Illustrator CS2
JavaScript Scripting Reference 5
invertMatrix..............................................................................................................................................................................76
isEqualMatrix ...........................................................................................................................................................................76
isSingularMatrix......................................................................................................................................................................76
open............................................................................................................................................................................................77
quit ..............................................................................................................................................................................................77
redraw ........................................................................................................................................................................................77
showPresets .............................................................................................................................................................................77
translatePlaceholderText ....................................................................................................................................................77
Brush .................................................................................................................................................................................................79
Brush properties .....................................................................................................................................................................79
name...........................................................................................................................................................................................79
parent.........................................................................................................................................................................................79
typename..................................................................................................................................................................................79
Brush methods........................................................................................................................................................................79
applyTo ......................................................................................................................................................................................79
Brushes.............................................................................................................................................................................................80
Brushes properties.................................................................................................................................................................80
length .........................................................................................................................................................................................80
parent.........................................................................................................................................................................................80
typename..................................................................................................................................................................................80
Brushes methods....................................................................................................................................................................80
getByName...............................................................................................................................................................................80
index ...........................................................................................................................................................................................80
CharacterAttributes.....................................................................................................................................................................81
CharacterAttributes properties.........................................................................................................................................81
akiLeft.........................................................................................................................................................................................81
akiRight......................................................................................................................................................................................81
alignment..................................................................................................................................................................................81
alternateGlyphs ......................................................................................................................................................................81
autoLeading.............................................................................................................................................................................81
baselineDirection...................................................................................................................................................................81
baselinePosition .....................................................................................................................................................................81
baselineShift ............................................................................................................................................................................81
capitalization ...........................................................................................................................................................................81
connectionForms...................................................................................................................................................................81
contextualLigature ................................................................................................................................................................81
discretionaryLigature ...........................................................................................................................................................81
figureStyle.................................................................................................................................................................................81
fillColor.......................................................................................................................................................................................81
fractions.....................................................................................................................................................................................82
horizontalScale .......................................................................................................................................................................82
italics...........................................................................................................................................................................................82
kerningMethod.......................................................................................................................................................................82
language ...................................................................................................................................................................................82
leading .......................................................................................................................................................................................82
ligature.......................................................................................................................................................................................82
noBreak......................................................................................................................................................................................82
openTypePosition..................................................................................................................................................................82
ordinals ......................................................................................................................................................................................82
ornaments ................................................................................................................................................................................82
overprintFill..................................................................................................................
............................................................82
Adobe Illustrator CS2
JavaScript Scripting Reference 6
overprintStroke.......................................................................................................................................................................82
parent.........................................................................................................................................................................................82
proportionalMetrics ..............................................................................................................................................................82
rotation ......................................................................................................................................................................................82
size...............................................................................................................................................................................................82
strikeThrough ..........................................................................................................................................................................82
strokeColor ...............................................................................................................................................................................82
strokeWeight ...........................................................................................................................................................................82
stylisticAlternates...................................................................................................................................................................82
swash..........................................................................................................................................................................................83
tateChuYokoHorizontal .......................................................................................................................................................83
tateChuYokoVertical .............................................................................................................................................................83
textFont .....................................................................................................................................................................................83
titling ..........................................................................................................................................................................................83
tracking......................................................................................................................................................................................83
Tsume.........................................................................................................................................................................................83
typename..................................................................................................................................................................................83
underline...................................................................................................................................................................................83
verticalScale .............................................................................................................................................................................83
wariChuCharactersAfterBreak ...........................................................................................................................................83
wariChuCharactersBeforeBreak........................................................................................................................................83
wariChuEnabled .....................................................................................................................................................................83
wariChuJustification .............................................................................................................................................................83
wariChuLineGap.....................................................................................................................................................................83
wariChuLines ...........................................................................................................................................................................83
wariChuScale ...........................................................................................................................................................................83
Characters .......................................................................................................................................................................................85
Characters properties ...........................................................................................................................................................85
length .........................................................................................................................................................................................85
parent.........................................................................................................................................................................................85
typename..................................................................................................................................................................................85
Characters methods..............................................................................................................................................................85
add...............................................................................................................................................................................................85
addBefore .................................................................................................................................................................................85
index ...........................................................................................................................................................................................85
removeAll..................................................................................................................................................................................85
CharacterStyle ...............................................................................................................................................................................86
CharacterStyle properties ...................................................................................................................................................86
characterAttributes ...............................................................................................................................................................86
name...........................................................................................................................................................................................86
parent.........................................................................................................................................................................................86
typename..................................................................................................................................................................................86
CharacterStyle methods ......................................................................................................................................................86
applyTo ......................................................................................................................................................................................86
remove.......................................................................................................................................................................................86
CharacterStyles .............................................................................................................................................................................87
CharacterStyles properties .................................................................................................................................................87
length .........................................................................................................................................................................................87
parent.........................................................................................................................................................................................87
typename..................................................................................................................................................................................87
CharacterStyles methods ........................................................................................................
............................................87
Adobe Illustrator CS2
JavaScript Scripting Reference 7
add...............................................................................................................................................................................................87
getByName...............................................................................................................................................................................87
index ...........................................................................................................................................................................................87
removeAll..................................................................................................................................................................................87
CMYKColor......................................................................................................................................................................................89
CMYKColor properties..........................................................................................................................................................89
black............................................................................................................................................................................................89
cyan.............................................................................................................................................................................................89
magenta ....................................................................................................................................................................................89
typename..................................................................................................................................................................................89
yellow .........................................................................................................................................................................................89
CompoundPathItem ...................................................................................................................................................................90
CompoundPathItem properties .......................................................................................................................................90
artworkKnockout ...................................................................................................................................................................90
blendingMode ........................................................................................................................................................................90
controlBounds.........................................................................................................................................................................90
editable......................................................................................................................................................................................90
geometricBounds ..................................................................................................................................................................90
height .........................................................................................................................................................................................90
hidden........................................................................................................................................................................................90
isIsolated ...................................................................................................................................................................................90
layer.............................................................................................................................................................................................90
left................................................................................................................................................................................................90
locked.........................................................................................................................................................................................90
name...........................................................................................................................................................................................90
opacity .......................................................................................................................................................................................90
parent.........................................................................................................................................................................................90
pathItems..................................................................................................................................................................................90
position......................................................................................................................................................................................90
selected......................................................................................................................................................................................91
sliced...........................................................................................................................................................................................91
tags..............................................................................................................................................................................................91
top ...............................................................................................................................................................................................91
typename..................................................................................................................................................................................91
uRL...............................................................................................................................................................................................91
visibilityVariable .....................................................................................................................................................................91
visibleBounds ..........................................................................................................................................................................91
width...........................................................................................................................................................................................91
wrapInside ................................................................................................................................................................................91
wrapOffset................................................................................................................................................................................91
wrapped ....................................................................................................................................................................................91
zOrderPosition ........................................................................................................................................................................91
CompoundPathItem methods ..........................................................................................................................................91
duplicate ...................................................................................................................................................................................91
move...........................................................................................................................................................................................91
remove.......................................................................................................................................................................................91
resize...........................................................................................................................................................................................92
rotate ..........................................................................................................................................................................................92
transform...................................................................................................................................................................................92
translate.....................................................................................................................................................................................92
zOrder.........................................................................................................................
................................................................92
Adobe Illustrator CS2
JavaScript Scripting Reference 8
CompoundPathItems .................................................................................................................................................................94
CompoundPathItem methods ..........................................................................................................................................94
length .........................................................................................................................................................................................94
parent.........................................................................................................................................................................................94
typename..................................................................................................................................................................................94
CompoundPathItem methods ..........................................................................................................................................94
add...............................................................................................................................................................................................94
getByName...............................................................................................................................................................................94
index ...........................................................................................................................................................................................94
removeAll..................................................................................................................................................................................94
Dataset .............................................................................................................................................................................................95
Dataset properties .................................................................................................................................................................95
name...........................................................................................................................................................................................95
parent.........................................................................................................................................................................................95
typename..................................................................................................................................................................................95
Dataset methods....................................................................................................................................................................95
display ........................................................................................................................................................................................95
remove.......................................................................................................................................................................................95
update........................................................................................................................................................................................95
Datasets ...........................................................................................................................................................................................97
Datasets properties ...............................................................................................................................................................97
length .........................................................................................................................................................................................97
parent.........................................................................................................................................................................................97
typename..................................................................................................................................................................................97
Datasets methods ..................................................................................................................................................................97
add...............................................................................................................................................................................................97
getByName...............................................................................................................................................................................97
index ...........................................................................................................................................................................................97
removeAll..................................................................................................................................................................................97
Document .......................................................................................................................................................................................98
Document properties ...........................................................................................................................................................98
activeDataset...........................................................................................................................................................................98
activeLayer ...............................................................................................................................................................................98
activeView.................................................................................................................................................................................98
brushes ......................................................................................................................................................................................98
characterStyles........................................................................................................................................................................98
compoundPathItems............................................................................................................................................................98
cropBox......................................................................................................................................................................................98
cropStyle ...................................................................................................................................................................................98
dataSets .....................................................................................................................................................................................98
defaultFillColor .......................................................................................................................................................................98
defaultFilled .............................................................................................................................................................................98
defaultFillOverprint...............................................................................................................................................................98
defaultStrokeCap ...................................................................................................................................................................98
defaultStrokeColor ................................................................................................................................................................98
defaultStroked ........................................................................................................................................................................98
defaultStrokeDashes.............................................................................................................................................................99
defaultStrokeDashOffset.....................................................................................................................................................99
defaultStrokeJoin...................................................................................................................................................................99
defaultStrokeMiterLimit ......................................................................................................................................................99
defaultStrokeOverprint.........................................................................................................
...............................................99
Adobe Illustrator CS2
JavaScript Scripting Reference 9
defaultStrokeWidth...............................................................................................................................................................99
documentColorSpace...........................................................................................................................................................99
fullName....................................................................................................................................................................................99
geometricBounds ..................................................................................................................................................................99
gradients ...................................................................................................................................................................................99
graphicStyles ...........................................................................................................................................................................99
graphItems ...............................................................................................................................................................................99
groupItems...............................................................................................................................................................................99
height .........................................................................................................................................................................................99
inkList .........................................................................................................................................................................................99
kinsokuSet ................................................................................................................................................................................99
layers........................................................................................................................................................................................ 100
legacyTextItems................................................................................................................................................................... 100
meshItems ............................................................................................................................................................................. 100
mojikumiSet.......................................................................................................................................................................... 100
name........................................................................................................................................................................................ 100
outputResolution ................................................................................................................................................................ 100
pageItems.............................................................................................................................................................................. 100
pageOrigin............................................................................................................................................................................. 100
paragraphStyles................................................................................................................................................................... 100
parent...................................................................................................................................................................................... 100
path.......................................................................................................................................................................................... 100
pathItems............................................................................................................................................................................... 100
patterns .................................................................................................................................................................................. 100
placedItems........................................................................................................................................................................... 100
pluginItems ........................................................................................................................................................................... 100
printTiles................................................................................................................................................................................. 100
rasterItems............................................................................................................................................................................. 100
rulerOrigin ............................................................................................................................................................................. 100
rulerUnits................................................................................................................................................................................ 101
saved........................................................................................................................................................................................ 101
selection ................................................................................................................................................................................. 101
showPlacedImages............................................................................................................................................................. 101
splitLongPaths ..................................................................................................................................................................... 101
spots......................................................................................................................................................................................... 101
stationery ............................................................................................................................................................................... 101
stories ...................................................................................................................................................................................... 101
swatches................................................................................................................................................................................. 101
symbolItems ......................................................................................................................................................................... 101
symbols................................................................................................................................................................................... 101
tags........................................................................................................................................................................................... 101
textFrames............................................................................................................................................................................. 101
tileFullPages.......................................................................................................................................................................... 101
typename............................................................................................................................................................................... 101
useDefaultScreen................................................................................................................................................................ 101
variables ................................................................................................................................................................................. 101
variablesLocked................................................................................................................................................................... 102
views........................................................................................................................................................................................ 102
visibleBounds ....................................................................................................................................................................... 102
width........................................................................................................................................................................................ 102
Document methods...............................................................................................................
............................................ 102
Adobe Illustrator CS2
JavaScript Scripting Reference 10
activate ................................................................................................................................................................................... 102
close......................................................................................................................................................................................... 102
exportFile ............................................................................................................................................................................... 102
exportPDFPreset ................................................................................................................................................................. 102
exportPrintPreset ................................................................................................................................................................ 102
exportVariables.................................................................................................................................................................... 102
importCharacterStyles ...................................................................................................................................................... 102
importParagraphStyles ..................................................................................................................................................... 102
importPDFPreset................................................................................................................................................................. 103
importPrintPreset................................................................................................................................................................ 103
importVariables ................................................................................................................................................................... 103
print.......................................................................................................................................................................................... 103
save .......................................................................................................................................................................................... 103
saveAs ..................................................................................................................................................................................... 103
Documents .................................................................................................................................................................................. 104
Documents properties ...................................................................................................................................................... 104
length ...................................................................................................................................................................................... 104
parent...................................................................................................................................................................................... 104
typename............................................................................................................................................................................... 104
Documents methods......................................................................................................................................................... 104
add............................................................................................................................................................................................ 104
getByName............................................................................................................................................................................ 104
index ........................................................................................................................................................................................ 104
EPSSaveOptions......................................................................................................................................................................... 105
EPSSaveOptions properties............................................................................................................................................. 105
cmykPostScript .................................................................................................................................................................... 105
compatibility......................................................................................................................................................................... 105
compatibleGradientPrinting........................................................................................................................................... 105
embedAllFonts..................................................................................................................................................................... 105
embedLinkedFiles............................................................................................................................................................... 105
flattenOuput ......................................................................................................................................................................... 105
includeDocumentThumbnails ....................................................................................................................................... 105
overprint................................................................................................................................................................................. 105
postScript............................................................................................................................................................................... 105
preview ................................................................................................................................................................................... 105
typename............................................................................................................................................................................... 105
ExportOptionsFlash .................................................................................................................................................................. 107
ExportOptionsFlash properties...................................................................................................................................... 107
artBoardClipping................................................................................................................................................................. 107
backgroundColor................................................................................................................................................................ 107
backgroundLayers .............................................................................................................................................................. 107
blendAnimation .................................................................................................................................................................. 107
compressed........................................................................................................................................................................... 107
convertTextToOutlines ..................................................................................................................................................... 107
curveQuality.......................................................................................................................................................................... 107
exportStyle ............................................................................................................................................................................ 107
flattenOutput........................................................................................................................................................................ 107
frameRate............................................................................................................................................................................... 107
generateHTML ..................................................................................................................................................................... 107
imageFormat ........................................................................................................................................................................ 107
jpegMethod .....................................................................................................................
..................................................... 107
Adobe Illustrator CS2
JavaScript Scripting Reference 11
jpegQuality............................................................................................................................................................................ 107
layerOrder.............................................................................................................................................................................. 107
looping.................................................................................................................................................................................... 108
readOnly................................................................................................................................................................................. 108
replacing ................................................................................................................................................................................ 108
resolution............................................................................................................................................................................... 108
typename............................................................................................................................................................................... 108
ExportOptionsGIF...................................................................................................................................................................... 109
ExportOptionsGIF properties.......................................................................................................................................... 109
antiAliasing............................................................................................................................................................................ 109
artBoardClipping................................................................................................................................................................. 109
colorCount............................................................................................................................................................................. 109
colorDither............................................................................................................................................................................. 109
colorReduction..................................................................................................................................................................... 109
ditherPercent........................................................................................................................................................................ 109
horizontalScale .................................................................................................................................................................... 109
infoLossPercent ................................................................................................................................................................... 109
interlaced ............................................................................................................................................................................... 109
matte ....................................................................................................................................................................................... 109
matteColor............................................................................................................................................................................. 109
saveAsHTML.......................................................................................................................................................................... 109
transparency ......................................................................................................................................................................... 109
typename............................................................................................................................................................................... 109
verticalScale .......................................................................................................................................................................... 110
webSnap ................................................................................................................................................................................ 110
ExportOptionsJPEG................................................................................................................................................................... 111
ExportOptionsJPEG properties ...................................................................................................................................... 111
antiAliasing............................................................................................................................................................................ 111
artBoardClipping................................................................................................................................................................. 111
blurAmount........................................................................................................................................................................... 111
horizontalScale .................................................................................................................................................................... 111
matte ....................................................................................................................................................................................... 111
matteColor............................................................................................................................................................................. 111
optimization.......................................................................................................................................................................... 111
qualitySetting ....................................................................................................................................................................... 111
saveAsHTML.......................................................................................................................................................................... 111
typename............................................................................................................................................................................... 111
verticalScale .......................................................................................................................................................................... 111
ExportOptionsPhotoshop ...................................................................................................................................................... 112
ExportOptionsPhotoshop properties .......................................................................................................................... 112
antiAliasing............................................................................................................................................................................ 112
compatibility......................................................................................................................................................................... 112
editableText .......................................................................................................................................................................... 112
embedICCProfile ................................................................................................................................................................. 112
imageColorSpace................................................................................................................................................................ 112
maximumEditability........................................................................................................................................................... 112
resolution............................................................................................................................................................................... 112
typename............................................................................................................................................................................... 112
warnings................................................................................................................................................................................. 112
writeLayers ............................................................................................................................................................................ 112
ExportOptionsPNG8 ..............................................................................................................
................................................... 113
Adobe Illustrator CS2
JavaScript Scripting Reference 12
ExportOptionsPNG8 properties..................................................................................................................................... 113
antiAliasing............................................................................................................................................................................ 113
artBoardClipping................................................................................................................................................................. 113
colorCount............................................................................................................................................................................. 113
colorDither............................................................................................................................................................................. 113
colorReduction..................................................................................................................................................................... 113
ditherPercent........................................................................................................................................................................ 113
horizontalScale .................................................................................................................................................................... 113
interlaced ............................................................................................................................................................................... 113
matte ....................................................................................................................................................................................... 113
matteColor............................................................................................................................................................................. 113
saveAsHTML.......................................................................................................................................................................... 113
transparency ......................................................................................................................................................................... 113
typename............................................................................................................................................................................... 113
verticalScale .......................................................................................................................................................................... 113
webSnap ................................................................................................................................................................................ 113
ExportOptionsPNG24............................................................................................................................................................... 115
ExportOptionsPNG24 properties .................................................................................................................................. 115
antiAliasing............................................................................................................................................................................ 115
artBoardClipping................................................................................................................................................................. 115
horizontalScale .................................................................................................................................................................... 115
matte ....................................................................................................................................................................................... 115
matteColor............................................................................................................................................................................. 115
saveAsHTML.......................................................................................................................................................................... 115
transparency ......................................................................................................................................................................... 115
typename............................................................................................................................................................................... 115
verticalScale .......................................................................................................................................................................... 115
ExportOptionsSVG .................................................................................................................................................................... 116
ExportOptionsSVG properties ........................................................................................................................................ 116
compressed........................................................................................................................................................................... 116
coordinatePrecision ........................................................................................................................................................... 116
cssProperties......................................................................................................................................................................... 116
documentEncoding ........................................................................................................................................................... 116
DTD........................................................................................................................................................................................... 116
embedRasterImages .......................................................................................................................................................... 116
fontSubsetting ..................................................................................................................................................................... 116
fontType ................................................................................................................................................................................. 116
includeFileInfo ..................................................................................................................................................................... 116
includeVariablesAndDatasets ........................................................................................................................................ 116
optimizeForSVGViewer ..................................................................................................................................................... 116
preserveEditability.............................................................................................................................................................. 116
slices......................................................................................................................................................................................... 117
sVGAutoKerning.................................................................................................................................................................. 117
sVGTextOnPath.................................................................................................................................................................... 117
typename............................................................................................................................................................................... 117
Gradient ........................................................................................................................................................................................ 118
Gradient properties............................................................................................................................................................ 118
gradientStops....................................................................................................................................................................... 118
name........................................................................................................................................................................................ 118
parent...................................................................................................................................................................................... 118
type ...........................................................................................................................
............................................................... 118
Adobe Illustrator CS2
JavaScript Scripting Reference 13
typename............................................................................................................................................................................... 118
Gradient methods............................................................................................................................................................... 118
remove.................................................................................................................................................................................... 118
GradientColor ............................................................................................................................................................................. 120
GradientColor properties ................................................................................................................................................. 120
angle........................................................................................................................................................................................ 120
gradient .................................................................................................................................................................................. 120
hiliteAngle ............................................................................................................................................................................. 120
hiliteLength........................................................................................................................................................................... 120
length ...................................................................................................................................................................................... 120
matrix ...................................................................................................................................................................................... 120
origin ....................................................................................................................................................................................... 120
typename............................................................................................................................................................................... 120
Gradients ...................................................................................................................................................................................... 121
Gradients properties.......................................................................................................................................................... 121
length ...................................................................................................................................................................................... 121
parent...................................................................................................................................................................................... 121
typename............................................................................................................................................................................... 121
Gradients methods............................................................................................................................................................. 121
add............................................................................................................................................................................................ 121
getByName............................................................................................................................................................................ 121
index ........................................................................................................................................................................................ 121
removeAll............................................................................................................................................................................... 121
GradientStop............................................................................................................................................................................... 122
GradientStop properties................................................................................................................................................... 122
color ......................................................................................................................................................................................... 122
midPoint................................................................................................................................................................................. 122
parent...................................................................................................................................................................................... 122
rampPoint.............................................................................................................................................................................. 122
typename............................................................................................................................................................................... 122
GradientStop methods ..................................................................................................................................................... 122
remove.................................................................................................................................................................................... 122
GradientStops............................................................................................................................................................................. 123
GradientStops properties................................................................................................................................................. 123
length ...................................................................................................................................................................................... 123
parent...................................................................................................................................................................................... 123
typename............................................................................................................................................................................... 123
GradientStops methods ................................................................................................................................................... 123
add............................................................................................................................................................................................ 123
index ........................................................................................................................................................................................ 123
removeAll............................................................................................................................................................................... 123
GraphicStyle ................................................................................................................................................................................ 124
GraphicStyle properties.................................................................................................................................................... 124
name........................................................................................................................................................................................ 124
parent...................................................................................................................................................................................... 124
typename............................................................................................................................................................................... 124
GraphicStyle methods....................................................................................................................................................... 124
applyTo ................................................................................................................................................................................... 124
remove.................................................................................................................................................................................... 124
GraphicStyles .............................................................................................................................................................................. 125
GraphicStyles properties .......................................................................................................
........................................... 125
Adobe Illustrator CS2
JavaScript Scripting Reference 14
length ...................................................................................................................................................................................... 125
parent...................................................................................................................................................................................... 125
typename............................................................................................................................................................................... 125
GraphicStyles methods..................................................................................................................................................... 125
getByName............................................................................................................................................................................ 125
index ........................................................................................................................................................................................ 125
removeAll............................................................................................................................................................................... 125
GraphItem.................................................................................................................................................................................... 126
GraphItem properties........................................................................................................................................................ 126
artworkKnockout ................................................................................................................................................................ 126
blendingMode ..................................................................................................................................................................... 126
contentVariable ................................................................................................................................................................... 126
controlBounds...................................................................................................................................................................... 126
editable................................................................................................................................................................................... 126
geometricBounds ............................................................................................................................................................... 126
height ...................................................................................................................................................................................... 126
hidden..................................................................................................................................................................................... 126
isIsolated ................................................................................................................................................................................ 126
layer.......................................................................................................................................................................................... 126
left............................................................................................................................................................................................. 126
locked...................................................................................................................................................................................... 126
name........................................................................................................................................................................................ 126
opacity .................................................................................................................................................................................... 126
parent...................................................................................................................................................................................... 126
position................................................................................................................................................................................... 126
selected................................................................................................................................................................................... 126
sliced........................................................................................................................................................................................ 126
tags........................................................................................................................................................................................... 126
top ............................................................................................................................................................................................ 126
typename............................................................................................................................................................................... 126
uRL............................................................................................................................................................................................ 127
visibilityVariable .................................................................................................................................................................. 127
visibleBounds ....................................................................................................................................................................... 127
width........................................................................................................................................................................................ 127
wrapInside ............................................................................................................................................................................. 127
wrapOffset............................................................................................................................................................................. 127
wrapped ................................................................................................................................................................................. 127
zOrderPosition ..................................................................................................................................................................... 127
GraphItem methods........................................................................................................................................................... 127
duplicate ................................................................................................................................................................................ 127
move........................................................................................................................................................................................ 127
remove.................................................................................................................................................................................... 127
resize........................................................................................................................................................................................ 127
rotate ....................................................................................................................................................................................... 128
transform................................................................................................................................................................................ 128
translate.................................................................................................................................................................................. 128
zOrder...................................................................................................................................................................................... 128
GraphItems .................................................................................................................................................................................. 129
GraphItems properties...................................................................................................................................................... 129
length ...................................................................................................................................................................................... 129
parent.........................................................................................................................
............................................................. 129
Adobe Illustrator CS2
JavaScript Scripting Reference 15
typename............................................................................................................................................................................... 129
GraphItems methods......................................................................................................................................................... 129
getByName............................................................................................................................................................................ 129
index ........................................................................................................................................................................................ 129
removeAll............................................................................................................................................................................... 129
GrayColor...................................................................................................................................................................................... 130
GrayColor properties ......................................................................................................................................................... 130
gray .......................................................................................................................................................................................... 130
typename............................................................................................................................................................................... 130
GroupItem.................................................................................................................................................................................... 131
GroupItem properties........................................................................................................................................................ 131
artworkKnockout ................................................................................................................................................................ 131
blendingMode ..................................................................................................................................................................... 131
clipped .................................................................................................................................................................................... 131
compoundPathItems......................................................................................................................................................... 131
controlBounds...................................................................................................................................................................... 131
editable................................................................................................................................................................................... 131
geometricBounds ............................................................................................................................................................... 131
graphItems ............................................................................................................................................................................ 131
groupItems............................................................................................................................................................................ 131
height ...................................................................................................................................................................................... 131
hidden..................................................................................................................................................................................... 131
isIsolated ................................................................................................................................................................................ 131
layer.......................................................................................................................................................................................... 131
left............................................................................................................................................................................................. 131
legacyTextItems................................................................................................................................................................... 131
locked...................................................................................................................................................................................... 131
meshItems ............................................................................................................................................................................. 131
name........................................................................................................................................................................................ 131
opacity .................................................................................................................................................................................... 131
pageItems.............................................................................................................................................................................. 132
parent...................................................................................................................................................................................... 132
pathItems............................................................................................................................................................................... 132
placedItems........................................................................................................................................................................... 132
pluginItems ........................................................................................................................................................................... 132
position................................................................................................................................................................................... 132
rasterItems............................................................................................................................................................................. 132
selected................................................................................................................................................................................... 132
sliced........................................................................................................................................................................................ 132
symbolItems ......................................................................................................................................................................... 132
tags........................................................................................................................................................................................... 132
textFrames............................................................................................................................................................................. 132
top ............................................................................................................................................................................................ 132
typename............................................................................................................................................................................... 132
uRL............................................................................................................................................................................................ 132
visibilityVariable .................................................................................................................................................................. 132
visibleBounds ....................................................................................................................................................................... 132
width........................................................................................................................................................................................ 132
wrapInside ............................................................................................................................................................................. 132
wrapOffset............................................................................................................................................................................. 132
wrapped ........................................................................................................................
......................................................... 132
Adobe Illustrator CS2
JavaScript Scripting Reference 16
zOrderPosition ..................................................................................................................................................................... 132
GroupItem methods .......................................................................................................................................................... 133
duplicate ................................................................................................................................................................................ 133
move........................................................................................................................................................................................ 133
remove.................................................................................................................................................................................... 133
resize........................................................................................................................................................................................ 133
rotate ....................................................................................................................................................................................... 133
transform................................................................................................................................................................................ 133
translate.................................................................................................................................................................................. 133
zOrder...................................................................................................................................................................................... 133
GroupItems.................................................................................................................................................................................. 135
GroupItems properties...................................................................................................................................................... 135
length ...................................................................................................................................................................................... 135
parent...................................................................................................................................................................................... 135
typename............................................................................................................................................................................... 135
GroupItems methods ........................................................................................................................................................ 135
add............................................................................................................................................................................................ 135
createFromFile ..................................................................................................................................................................... 135
getByName............................................................................................................................................................................ 135
index ........................................................................................................................................................................................ 135
removeAll............................................................................................................................................................................... 135
IllustratorSaveOptions............................................................................................................................................................. 136
IllustratorSaveOptions properties................................................................................................................................. 136
compatibility......................................................................................................................................................................... 136
compressed........................................................................................................................................................................... 136
embedICCProfile ................................................................................................................................................................. 136
embedLinkedFiles............................................................................................................................................................... 136
flattenOutput........................................................................................................................................................................ 136
fontSubsetThreshold ......................................................................................................................................................... 136
overprint................................................................................................................................................................................. 136
pdfCompatible..................................................................................................................................................................... 136
typename............................................................................................................................................................................... 136
Ink.................................................................................................................................................................................................... 137
Ink properties ....................................................................................................................................................................... 137
inkInfo ..................................................................................................................................................................................... 137
name........................................................................................................................................................................................ 137
typename............................................................................................................................................................................... 137
InkInfo............................................................................................................................................................................................ 137
InkInfo properties................................................................................................................................................................ 137
angle........................................................................................................................................................................................ 137
customColor ......................................................................................................................................................................... 137
density..................................................................................................................................................................................... 137
dotShape................................................................................................................................................................................ 137
frequency............................................................................................................................................................................... 137
kind........................................................................................................................................................................................... 137
printingStatus....................................................................................................................................................................... 137
trapping.................................................................................................................................................................................. 137
trappingOrder ...................................................................................................................................................................... 137
typename............................................................................................................................................................................... 137
InsertionPoint ............................................................................................................................................................................. 139
InsertionPoints ................................................................................................................
........................................................... 139
Adobe Illustrator CS2
JavaScript Scripting Reference 17
InsertionPoints properties ............................................................................................................................................... 139
length ...................................................................................................................................................................................... 139
parent...................................................................................................................................................................................... 139
typename............................................................................................................................................................................... 139
InsertionPoints methods .................................................................................................................................................. 139
index ........................................................................................................................................................................................ 139
LabColor ....................................................................................................................................................................................... 140
LabColor properties ........................................................................................................................................................... 140
a................................................................................................................................................................................................. 140
b................................................................................................................................................................................................. 140
l .................................................................................................................................................................................................. 140
typename............................................................................................................................................................................... 140
Layer............................................................................................................................................................................................... 141
Layer properties................................................................................................................................................................... 141
artworkKnockout ................................................................................................................................................................ 141
blendingMode ..................................................................................................................................................................... 141
color ......................................................................................................................................................................................... 141
compoundPathItems......................................................................................................................................................... 141
dimPlacedImages................................................................................................................................................................ 141
graphItems ............................................................................................................................................................................ 141
groupItems............................................................................................................................................................................ 141
hasSelectedArtwork........................................................................................................................................................... 141
isIsolated ................................................................................................................................................................................ 141
layers........................................................................................................................................................................................ 141
legacyTextItems................................................................................................................................................................... 141
locked...................................................................................................................................................................................... 141
meshItems ............................................................................................................................................................................. 141
name........................................................................................................................................................................................ 141
opacity .................................................................................................................................................................................... 141
pageItems.............................................................................................................................................................................. 141
parent...................................................................................................................................................................................... 141
pathItems............................................................................................................................................................................... 142
placedItems........................................................................................................................................................................... 142
pluginItems ........................................................................................................................................................................... 142
preview ................................................................................................................................................................................... 142
printable................................................................................................................................................................................. 142
rasterItems............................................................................................................................................................................. 142
sliced........................................................................................................................................................................................ 142
symbolItems ......................................................................................................................................................................... 142
textFrames............................................................................................................................................................................. 142
typename............................................................................................................................................................................... 142
visible....................................................................................................................................................................................... 142
zOrderPosition ..................................................................................................................................................................... 142
Layer methods ..................................................................................................................................................................... 142
move........................................................................................................................................................................................ 142
remove.................................................................................................................................................................................... 142
zOrder...................................................................................................................................................................................... 142
Layers............................................................................................................................................................................................. 144
Layers properties................................................................................................................................................................. 144
length ...................................................................................................................................................................................... 144
parent.........................................................................................................................
............................................................. 144
Adobe Illustrator CS2
JavaScript Scripting Reference 18
typename............................................................................................................................................................................... 144
Layers methods.................................................................................................................................................................... 144
add............................................................................................................................................................................................ 144
getByName............................................................................................................................................................................ 144
index ........................................................................................................................................................................................ 144
removeAll............................................................................................................................................................................... 144
LegacyTextItem.......................................................................................................................................................................... 145
LegacyTextItem properties ............................................................................................................................................. 145
artworkKnockout ................................................................................................................................................................ 145
blendingMode ..................................................................................................................................................................... 145
controlBounds...................................................................................................................................................................... 145
converted............................................................................................................................................................................... 145
editable................................................................................................................................................................................... 145
geometricBounds ............................................................................................................................................................... 145
height ...................................................................................................................................................................................... 145
hidden..................................................................................................................................................................................... 145
isIsolated ................................................................................................................................................................................ 145
layer.......................................................................................................................................................................................... 145
left............................................................................................................................................................................................. 145
locked...................................................................................................................................................................................... 145
name........................................................................................................................................................................................ 145
opacity .................................................................................................................................................................................... 145
parent...................................................................................................................................................................................... 145
position................................................................................................................................................................................... 145
selected................................................................................................................................................................................... 145
sliced........................................................................................................................................................................................ 145
tags........................................................................................................................................................................................... 145
top ............................................................................................................................................................................................ 145
typename............................................................................................................................................................................... 145
uRL............................................................................................................................................................................................ 145
visibilityVariable .................................................................................................................................................................. 145
visibleBounds ....................................................................................................................................................................... 146
width........................................................................................................................................................................................ 146
wrapInside ............................................................................................................................................................................. 146
wrapOffset............................................................................................................................................................................. 146
wrapped ................................................................................................................................................................................. 146
zOrderPosition ..................................................................................................................................................................... 146
LegacyTextItem methods ................................................................................................................................................ 146
convertToNative.................................................................................................................................................................. 146
duplicate ................................................................................................................................................................................ 146
move........................................................................................................................................................................................ 146
remove.................................................................................................................................................................................... 146
resize........................................................................................................................................................................................ 146
rotate ....................................................................................................................................................................................... 146
transform................................................................................................................................................................................ 147
translate.................................................................................................................................................................................. 147
zOrder...................................................................................................................................................................................... 147
LegacyTextItems........................................................................................................................................................................ 148
LegacyTextItems properties............................................................................................................................................ 148
length ...................................................................................................................................................................................... 148
parent.........................................................................................................................
............................................................. 148
Adobe Illustrator CS2
JavaScript Scripting Reference 19
typename............................................................................................................................................................................... 148
LegacyTextItems methods .............................................................................................................................................. 148
convertToNative.................................................................................................................................................................. 148
getByName............................................................................................................................................................................ 148
index ........................................................................................................................................................................................ 148
removeAll............................................................................................................................................................................... 148
Lines ............................................................................................................................................................................................... 149
Lines properties ................................................................................................................................................................... 149
length ...................................................................................................................................................................................... 149
parent...................................................................................................................................................................................... 149
typename............................................................................................................................................................................... 149
Lines methods...................................................................................................................................................................... 149
index ........................................................................................................................................................................................ 149
removeAll............................................................................................................................................................................... 149
Matrix............................................................................................................................................................................................. 150
Matrix properties................................................................................................................................................................. 150
mValueA ................................................................................................................................................................................. 150
mValueB ................................................................................................................................................................................. 150
mValueC ................................................................................................................................................................................. 150
mValueD................................................................................................................................................................................. 150
mValueTX............................................................................................................................................................................... 150
mValueTY ............................................................................................................................................................................... 150
typename............................................................................................................................................................................... 150
MeshItem...................................................................................................................................................................................... 151
MeshItem properties ......................................................................................................................................................... 151
artworkKnockout ................................................................................................................................................................ 151
blendingMode ..................................................................................................................................................................... 151
controlBounds...................................................................................................................................................................... 151
editable................................................................................................................................................................................... 151
geometricBounds ............................................................................................................................................................... 151
height ...................................................................................................................................................................................... 151
hidden..................................................................................................................................................................................... 151
isIsolated ................................................................................................................................................................................ 151
layer.......................................................................................................................................................................................... 151
left............................................................................................................................................................................................. 151
locked...................................................................................................................................................................................... 151
name........................................................................................................................................................................................ 151
opacity .................................................................................................................................................................................... 151
parent...................................................................................................................................................................................... 151
position................................................................................................................................................................................... 151
selected................................................................................................................................................................................... 151
sliced........................................................................................................................................................................................ 151
tags........................................................................................................................................................................................... 151
top ............................................................................................................................................................................................ 151
typename............................................................................................................................................................................... 151
uRL............................................................................................................................................................................................ 151
visibilityVariable .................................................................................................................................................................. 151
visibleBounds ....................................................................................................................................................................... 151
width........................................................................................................................................................................................ 152
wrapInside ............................................................................................................................................................................. 152
wrapOffset.....................................................................................................................
........................................................ 152
Adobe Illustrator CS2
JavaScript Scripting Reference 20
wrapped ................................................................................................................................................................................. 152
zOrderPosition ..................................................................................................................................................................... 152
MeshItem methods ............................................................................................................................................................ 152
duplicate ................................................................................................................................................................................ 152
move........................................................................................................................................................................................ 152
remove.................................................................................................................................................................................... 152
resize........................................................................................................................................................................................ 152
rotate ....................................................................................................................................................................................... 152
transform................................................................................................................................................................................ 152
translate.................................................................................................................................................................................. 153
zOrder...................................................................................................................................................................................... 153
MeshItems.................................................................................................................................................................................... 154
MeshItems properties........................................................................................................................................................ 154
length ...................................................................................................................................................................................... 154
parent...................................................................................................................................................................................... 154
typename............................................................................................................................................................................... 154
MeshItems methods .......................................................................................................................................................... 154
getByName............................................................................................................................................................................ 154
index ........................................................................................................................................................................................ 154
removeAll............................................................................................................................................................................... 154
NoColor......................................................................................................................................................................................... 155
NoColor properties............................................................................................................................................................. 155
typename............................................................................................................................................................................... 155
OpenOptions .............................................................................................................................................................................. 156
OpenOptions properties .................................................................................................................................................. 156
typename............................................................................................................................................................................... 156
updateLegacyText .............................................................................................................................................................. 156
PageItems..................................................................................................................................................................................... 157
PageItems properties ........................................................................................................................................................ 157
length ...................................................................................................................................................................................... 157
parent...................................................................................................................................................................................... 157
typename............................................................................................................................................................................... 157
PageItems methods ........................................................................................................................................................... 157
getByName............................................................................................................................................................................ 157
index ........................................................................................................................................................................................ 157
removeAll............................................................................................................................................................................... 157
Paper.............................................................................................................................................................................................. 159
Paper properties.................................................................................................................................................................. 159
name........................................................................................................................................................................................ 159
paperInfo................................................................................................................................................................................ 159
typename............................................................................................................................................................................... 159
PaperInfo ...................................................................................................................................................................................... 159
PaperInfo properties.......................................................................................................................................................... 159
customPaper......................................................................................................................................................................... 159
height ...................................................................................................................................................................................... 159
imageableArea..................................................................................................................................................................... 159
typename............................................................................................................................................................................... 159
width........................................................................................................................................................................................ 159
ParagraphAttributes................................................................................................................................................................. 161
ParagraphAttributes properties .................................................................................................................................... 161
autoLeadingAmount ..............................................................................................................
........................................... 161
Adobe Illustrator CS2
JavaScript Scripting Reference 21
bunriKinshi ............................................................................................................................................................................ 161
burasagariType .................................................................................................................................................................... 161
desiredGlyphScaling.......................................................................................................................................................... 161
desiredLetterSpacing ........................................................................................................................................................ 161
desiredWordSpacing ......................................................................................................................................................... 161
everyLineComposer ........................................................................................................................................................... 161
firstLineIndent...................................................................................................................................................................... 161
hyphenateCapitalizedWords .......................................................................................................................................... 161
hyphenation ......................................................................................................................................................................... 161
hyphenationPreference.................................................................................................................................................... 161
hyphenationZone ............................................................................................................................................................... 161
justification............................................................................................................................................................................ 161
kinsoku.................................................................................................................................................................................... 161
kinsokuOrder ........................................................................................................................................................................ 161
kurikaeshiMojiShori............................................................................................................................................................ 161
leadingType .......................................................................................................................................................................... 161
leftIndent................................................................................................................................................................................ 161
maximumConsecutiveHyphens .................................................................................................................................... 161
maximumGlyphScaling .................................................................................................................................................... 161
maximumLetterSpacing................................................................................................................................................... 162
maximumWordSpacing.................................................................................................................................................... 162
minimumAfterHyphen...................................................................................................................................................... 162
minimumBeforeHyphen................................................................................................................................................... 162
minimumGlyphScaling ..................................................................................................................................................... 162
minimumHyphenatedWordSize.................................................................................................................................... 162
minimumLetterSpacing.................................................................................................................................................... 162
minimumWordSpacing .................................................................................................................................................... 162
mojikumi ................................................................................................................................................................................ 162
parent...................................................................................................................................................................................... 162
rightIndent ............................................................................................................................................................................ 162
romanHanging..................................................................................................................................................................... 162
singleWordJustification .................................................................................................................................................... 162
spaceAfter.............................................................................................................................................................................. 162
spaceBefore........................................................................................................................................................................... 162
tabStops ................................................................................................................................................................................. 162
typename............................................................................................................................................................................... 162
Paragraphs................................................................................................................................................................................... 164
Paragraphs properties....................................................................................................................................................... 164
length ...................................................................................................................................................................................... 164
parent...................................................................................................................................................................................... 164
typename............................................................................................................................................................................... 164
Paragraphs methods.......................................................................................................................................................... 164
add............................................................................................................................................................................................ 164
addBefore .............................................................................................................................................................................. 164
index ........................................................................................................................................................................................ 164
removeAll............................................................................................................................................................................... 164
ParagraphStyle........................................................................................................................................................................... 165
ParagraphStyle properties............................................................................................................................................... 165
characterAttributes ............................................................................................................................................................ 165
name........................................................................................................................................................................................ 165
paragraphAttributes ............................................................................................................
.............................................. 165
Adobe Illustrator CS2
JavaScript Scripting Reference 22
parent...................................................................................................................................................................................... 165
typename............................................................................................................................................................................... 165
ParagraphStyle methods.................................................................................................................................................. 165
applyTo ................................................................................................................................................................................... 165
remove.................................................................................................................................................................................... 165
ParagraphStyles ......................................................................................................................................................................... 166
ParagraphStyles properties............................................................................................................................................. 166
length ...................................................................................................................................................................................... 166
parent...................................................................................................................................................................................... 166
typename............................................................................................................................................................................... 166
ParagraphStyles methods................................................................................................................................................ 166
add............................................................................................................................................................................................ 166
getByName............................................................................................................................................................................ 166
index ........................................................................................................................................................................................ 166
removeAll............................................................................................................................................................................... 166
PathItem ....................................................................................................................................................................................... 168
PathItem properties ........................................................................................................................................................... 168
area........................................................................................................................................................................................... 168
artworkKnockout ................................................................................................................................................................ 168
blendingMode ..................................................................................................................................................................... 168
clipping................................................................................................................................................................................... 168
closed ...................................................................................................................................................................................... 168
controlBounds...................................................................................................................................................................... 168
editable................................................................................................................................................................................... 168
evenodd ................................................................................................................................................................................. 168
fillColor.................................................................................................................................................................................... 168
filled ......................................................................................................................................................................................... 168
fillOverprint ........................................................................................................................................................................... 168
geometricBounds ............................................................................................................................................................... 168
guides...................................................................................................................................................................................... 168
height ...................................................................................................................................................................................... 168
hidden..................................................................................................................................................................................... 168
isIsolated ................................................................................................................................................................................ 168
layer.......................................................................................................................................................................................... 168
left............................................................................................................................................................................................. 168
locked...................................................................................................................................................................................... 168
name........................................................................................................................................................................................ 168
note.......................................................................................................................................................................................... 169
opacity .................................................................................................................................................................................... 169
parent...................................................................................................................................................................................... 169
pathPoints ............................................................................................................................................................................. 169
polarity.................................................................................................................................................................................... 169
position................................................................................................................................................................................... 169
resolution............................................................................................................................................................................... 169
selected................................................................................................................................................................................... 169
selectedPathPoints............................................................................................................................................................. 169
sliced........................................................................................................................................................................................ 169
strokeCap ............................................................................................................................................................................... 169
strokeColor ............................................................................................................................................................................ 169
stroked .................................................................................................................................................................................... 169
strokeDashes ...................................................................................................................
..................................................... 169
Adobe Illustrator CS2
JavaScript Scripting Reference 23
strokeDashOffset................................................................................................................................................................. 169
strokeJoin............................................................................................................................................................................... 169
strokeMiterLimit .................................................................................................................................................................. 169
strokeOverprint.................................................................................................................................................................... 169
strokeWidth........................................................................................................................................................................... 169
tags........................................................................................................................................................................................... 169
top ............................................................................................................................................................................................ 169
typename............................................................................................................................................................................... 169
uRL............................................................................................................................................................................................ 169
visibilityVariable .................................................................................................................................................................. 169
visibleBounds ....................................................................................................................................................................... 170
width........................................................................................................................................................................................ 170
wrapInside ............................................................................................................................................................................. 170
wrapOffset............................................................................................................................................................................. 170
wrapped ................................................................................................................................................................................. 170
zOrderPosition ..................................................................................................................................................................... 170
PathItem methods.............................................................................................................................................................. 170
duplicate ................................................................................................................................................................................ 170
move........................................................................................................................................................................................ 170
remove.................................................................................................................................................................................... 170
resize........................................................................................................................................................................................ 170
rotate ....................................................................................................................................................................................... 170
setEntirePath ........................................................................................................................................................................ 170
transform................................................................................................................................................................................ 171
translate.................................................................................................................................................................................. 171
zOrder...................................................................................................................................................................................... 171
PathItems ..................................................................................................................................................................................... 172
PathItems properties ......................................................................................................................................................... 172
length ...................................................................................................................................................................................... 172
parent...................................................................................................................................................................................... 172
typename............................................................................................................................................................................... 172
PathItems methods............................................................................................................................................................ 172
add............................................................................................................................................................................................ 172
ellipse ...................................................................................................................................................................................... 172
getByName............................................................................................................................................................................ 172
index ........................................................................................................................................................................................ 172
polygon .................................................................................................................................................................................. 172
rectangle ................................................................................................................................................................................ 172
removeAll............................................................................................................................................................................... 172
roundedRectangle.............................................................................................................................................................. 173
star............................................................................................................................................................................................ 173
PathPoint...................................................................................................................................................................................... 174
PathPoint properties.......................................................................................................................................................... 174
anchor ..................................................................................................................................................................................... 174
leftDirection .......................................................................................................................................................................... 174
parent...................................................................................................................................................................................... 174
pointType............................................................................................................................................................................... 174
rightDirection ....................................................................................................................................................................... 174
selected................................................................................................................................................................................... 174
typename............................................................................................................................................................................... 174
PathPoint methods ..............................................................................................................
.............................................. 174
Adobe Illustrator CS2
JavaScript Scripting Reference 24
remove.................................................................................................................................................................................... 174
PathPoints.................................................................................................................................................................................... 175
PathPoints properties........................................................................................................................................................ 175
length ...................................................................................................................................................................................... 175
parent...................................................................................................................................................................................... 175
typename............................................................................................................................................................................... 175
PathPoints methods........................................................................................................................................................... 175
add............................................................................................................................................................................................ 175
index ........................................................................................................................................................................................ 175
removeAll............................................................................................................................................................................... 175
Pattern........................................................................................................................................................................................... 176
Pattern properties............................................................................................................................................................... 176
name........................................................................................................................................................................................ 176
parent...................................................................................................................................................................................... 176
typename............................................................................................................................................................................... 176
Pattern methods.................................................................................................................................................................. 176
remove.................................................................................................................................................................................... 176
toString................................................................................................................................................................................... 176
Patterns......................................................................................................................................................................................... 176
Patterns properties............................................................................................................................................................. 176
length ...................................................................................................................................................................................... 176
parent...................................................................................................................................................................................... 176
typename............................................................................................................................................................................... 176
Patterns methods................................................................................................................................................................ 176
add............................................................................................................................................................................................ 176
getByName............................................................................................................................................................................ 176
index ........................................................................................................................................................................................ 177
removeAll............................................................................................................................................................................... 177
PatternColor ................................................................................................................................................................................ 178
PatternColor properties.................................................................................................................................................... 178
matrix ...................................................................................................................................................................................... 178
pattern .................................................................................................................................................................................... 178
reflect....................................................................................................................................................................................... 178
reflectAngle........................................................................................................................................................................... 178
rotation ................................................................................................................................................................................... 178
scaleFactor............................................................................................................................................................................. 178
shearAngle............................................................................................................................................................................. 178
shearAxis ................................................................................................................................................................................ 178
shiftAngle............................................................................................................................................................................... 178
shiftDistance ......................................................................................................................................................................... 178
typename............................................................................................................................................................................... 178
PDFFileOptions .......................................................................................................................................................................... 180
PDFFileOptions properties .............................................................................................................................................. 180
pageToOpen......................................................................................................................................................................... 180
parent...................................................................................................................................................................................... 180
pDFCropToBox..................................................................................................................................................................... 180
typename............................................................................................................................................................................... 180
PDFSaveOptions ........................................................................................................................................................................ 181
PDFSaveOptions properties............................................................................................................................................ 181
acrobatLayers ....................................................................................................................................................................... 181
bleedLink......................................................................................................................
.......................................................... 181
Adobe Illustrator CS2
JavaScript Scripting Reference 25
bleedOffsetRect................................................................................................................................................................... 181
colorBars................................................................................................................................................................................. 181
colorCompression............................................................................................................................................................... 181
colorConversionID.............................................................................................................................................................. 181
colorDestinationID ............................................................................................................................................................. 181
colorDownsampling .......................................................................................................................................................... 181
colorDownsamplingImageThreshold.......................................................................................................................... 181
colorDownsamplingMethod .......................................................................................................................................... 181
colorProfileID........................................................................................................................................................................ 181
colorTileSize .......................................................................................................................................................................... 181
compatibility......................................................................................................................................................................... 181
compressArt.......................................................................................................................................................................... 182
documentPassword ........................................................................................................................................................... 182
enableAccess ........................................................................................................................................................................ 182
enableCopy ........................................................................................................................................................................... 182
enableCopyAccess.............................................................................................................................................................. 182
enablePlainText ................................................................................................................................................................... 182
flattenerOptions .................................................................................................................................................................. 182
flattenerPreset...................................................................................................................................................................... 182
fontSubsetThreshold ......................................................................................................................................................... 182
generateThumbnails ......................................................................................................................................................... 182
grayscaleCompression ...................................................................................................................................................... 182
grayscaleDownsampling.................................................................................................................................................. 182
grayscaleDownsamplingImageThreshold................................................................................................................. 182
grayscaleDownsamplingMethod.................................................................................................................................. 183
grayscaleTileSize ................................................................................................................................................................. 183
monochromeCompression ............................................................................................................................................. 183
monochromeDownsampling ......................................................................................................................................... 183
monochromeDownsamplingImageThreshold ........................................................................................................ 183
monochromeDownsamplingMethod ......................................................................................................................... 183
offset........................................................................................................................................................................................ 183
optimization.......................................................................................................................................................................... 183
outputCondition ................................................................................................................................................................. 183
outputConditionID ............................................................................................................................................................. 183
pageInformation ................................................................................................................................................................. 183
pageMarksType ................................................................................................................................................................... 183
pDFAllowPrinting................................................................................................................................................................ 183
pDFChangesAllowed......................................................................................................................................................... 183
pDFPreset............................................................................................................................................................................... 184
pDFXStandard...................................................................................................................................................................... 184
pDFXStandardDescription............................................................................................................................................... 184
permissionPassword.......................................................................................................................................................... 184
preserveEditability.............................................................................................................................................................. 184
printerResolution ................................................................................................................................................................ 184
registrationMarks ................................................................................................................................................................ 184
requireDocumentPassword ............................................................................................................................................ 184
requirePermissionPassword............................................................................................................................................ 184
trapped ................................................................................................................................................................................... 184
trimMarks ............................................................................................................................................................................... 184
trimMarkWeight .................................................................................................................................................................. 184
typename............................................................................................................................................................................... 184
Adobe Illustrator CS2
JavaScript Scripting Reference 26
viewAfterSaving .................................................................................................................................................................. 184
PhotoshopFileOptions ............................................................................................................................................................ 186
PhotoshopFileOptions properties ................................................................................................................................ 186
parent...................................................................................................................................................................................... 186
pixelAspectRatioCorrection ............................................................................................................................................ 186
preserveImageMaps .......................................................................................................................................................... 186
preserveLayers ..................................................................................................................................................................... 186
preserveSlices....................................................................................................................................................................... 186
typename............................................................................................................................................................................... 186
PlacedItem ................................................................................................................................................................................... 187
PlacedItem properties....................................................................................................................................................... 187
artworkKnockout ................................................................................................................................................................ 187
blendingMode ..................................................................................................................................................................... 187
boundingBox........................................................................................................................................................................ 187
contentVariable ................................................................................................................................................................... 187
controlBounds...................................................................................................................................................................... 187
editable................................................................................................................................................................................... 187
file ............................................................................................................................................................................................. 187
geometricBounds ............................................................................................................................................................... 187
height ...................................................................................................................................................................................... 187
hidden..................................................................................................................................................................................... 187
isIsolated ................................................................................................................................................................................ 187
layer.......................................................................................................................................................................................... 187
left............................................................................................................................................................................................. 187
locked...................................................................................................................................................................................... 187
matrix ...................................................................................................................................................................................... 187
name........................................................................................................................................................................................ 187
opacity .................................................................................................................................................................................... 187
parent...................................................................................................................................................................................... 187
position................................................................................................................................................................................... 187
selected................................................................................................................................................................................... 187
sliced........................................................................................................................................................................................ 187
tags........................................................................................................................................................................................... 188
top ............................................................................................................................................................................................ 188
typename............................................................................................................................................................................... 188
uRL............................................................................................................................................................................................ 188
visibilityVariable .................................................................................................................................................................. 188
visibleBounds ....................................................................................................................................................................... 188
width........................................................................................................................................................................................ 188
wrapInside ............................................................................................................................................................................. 188
wrapOffset............................................................................................................................................................................. 188
wrapped ................................................................................................................................................................................. 188
zOrderPosition ..................................................................................................................................................................... 188
PlacedItem methods.......................................................................................................................................................... 188
duplicate ................................................................................................................................................................................ 188
embed..................................................................................................................................................................................... 188
move........................................................................................................................................................................................ 188
remove.................................................................................................................................................................................... 188
resize........................................................................................................................................................................................ 189
rotate ....................................................................................................................................................................................... 189
trace ..........................................................................................................................
............................................................... 189
Adobe Illustrator CS2
JavaScript Scripting Reference 27
transform................................................................................................................................................................................ 189
translate.................................................................................................................................................................................. 189
zOrder...................................................................................................................................................................................... 189
PlacedItems ................................................................................................................................................................................. 191
PlacedItems properties ..................................................................................................................................................... 191
length ...................................................................................................................................................................................... 191
parent...................................................................................................................................................................................... 191
typename............................................................................................................................................................................... 191
PlacedItems methods........................................................................................................................................................ 191
add............................................................................................................................................................................................ 191
getByName............................................................................................................................................................................ 191
index ........................................................................................................................................................................................ 191
removeAll............................................................................................................................................................................... 191
PluginItem.................................................................................................................................................................................... 192
PluginItem properties ....................................................................................................................................................... 192
artworkKnockout ................................................................................................................................................................ 192
blendingMode ..................................................................................................................................................................... 192
controlBounds...................................................................................................................................................................... 192
editable................................................................................................................................................................................... 192
geometricBounds ............................................................................................................................................................... 192
height ...................................................................................................................................................................................... 192
hidden..................................................................................................................................................................................... 192
isIsolated ................................................................................................................................................................................ 192
isTracing ................................................................................................................................................................................. 192
layer.......................................................................................................................................................................................... 192
left............................................................................................................................................................................................. 192
locked...................................................................................................................................................................................... 192
name........................................................................................................................................................................................ 192
opacity .................................................................................................................................................................................... 192
parent...................................................................................................................................................................................... 192
position................................................................................................................................................................................... 192
selected................................................................................................................................................................................... 192
sliced........................................................................................................................................................................................ 192
tags........................................................................................................................................................................................... 192
top ............................................................................................................................................................................................ 192
tracing ..................................................................................................................................................................................... 193
typename............................................................................................................................................................................... 193
uRL............................................................................................................................................................................................ 193
visibilityVariable .................................................................................................................................................................. 193
visibleBounds ....................................................................................................................................................................... 193
width........................................................................................................................................................................................ 193
wrapInside ............................................................................................................................................................................. 193
wrapOffset............................................................................................................................................................................. 193
wrapped ................................................................................................................................................................................. 193
zOrderPosition ..................................................................................................................................................................... 193
PluginItem methods .......................................................................................................................................................... 193
duplicate ................................................................................................................................................................................ 193
move........................................................................................................................................................................................ 193
remove.................................................................................................................................................................................... 193
resize........................................................................................................................................................................................ 193
rotate .........................................................................................................................
.............................................................. 194
Adobe Illustrator CS2
JavaScript Scripting Reference 28
transform................................................................................................................................................................................ 194
translate.................................................................................................................................................................................. 194
zOrder...................................................................................................................................................................................... 194
PluginItems.................................................................................................................................................................................. 195
PluginItems properties...................................................................................................................................................... 195
length ...................................................................................................................................................................................... 195
parent...................................................................................................................................................................................... 195
typename............................................................................................................................................................................... 195
PluginItems methods ........................................................................................................................................................ 195
getByName............................................................................................................................................................................ 195
index ........................................................................................................................................................................................ 195
removeAll............................................................................................................................................................................... 195
PPDFile .......................................................................................................................................................................................... 196
PPDFile properties .............................................................................................................................................................. 196
name........................................................................................................................................................................................ 196
pPDInfo................................................................................................................................................................................... 196
typename............................................................................................................................................................................... 196
PPDFileInfo .................................................................................................................................................................................. 196
PPDFileInfo properties ...................................................................................................................................................... 196
languageLevel...................................................................................................................................................................... 196
PPDFilePath........................................................................................................................................................................... 196
screenList ............................................................................................................................................................................... 196
screenSpotFunctionList.................................................................................................................................................... 196
typename............................................................................................................................................................................... 196
Preferences.................................................................................................................................................................................. 199
Preferences properties...................................................................................................................................................... 199
parent...................................................................................................................................................................................... 199
PDFFileOptions .................................................................................................................................................................... 199
photoshopFileOptions...................................................................................................................................................... 199
typename............................................................................................................................................................................... 199
PrintColorManagementOptions .......................................................................................................................................... 200
PrintColorManagementOptions properties .............................................................................................................. 200
colorProfileMode................................................................................................................................................................. 200
intent ....................................................................................................................................................................................... 200
name........................................................................................................................................................................................ 200
typename............................................................................................................................................................................... 200
PrintColorSeparationOptions ............................................................................................................................................... 201
PrintColorSeparationOptions properties ................................................................................................................... 201
colorSeparationMode........................................................................................................................................................ 201
convertSpotColors.............................................................................................................................................................. 201
inkList ...................................................................................................................................................................................... 201
overPrintBlack ...................................................................................................................................................................... 201
typename............................................................................................................................................................................... 201
PrintCoordinateOptions ......................................................................................................................................................... 202
PrintCoordinateOptions properties ............................................................................................................................. 202
emulsion................................................................................................................................................................................. 202
fitToPage ................................................................................................................................................................................ 202
horizontalScale .................................................................................................................................................................... 202
orientation............................................................................................................................................................................. 202
position................................................................................................................................................................................... 202
tiling.........................................................................................................................
................................................................ 202
Adobe Illustrator CS2
JavaScript Scripting Reference 29
typename............................................................................................................................................................................... 202
verticalScale .......................................................................................................................................................................... 202
Printer ............................................................................................................................................................................................ 203
Printer properties................................................................................................................................................................ 203
name........................................................................................................................................................................................ 203
printerInfo.............................................................................................................................................................................. 203
typename............................................................................................................................................................................... 203
PrinterInfo .................................................................................................................................................................................... 203
PrinterInfo properties ........................................................................................................................................................ 203
binaryPrintingSupport ...................................................................................................................................................... 203
colorSupport......................................................................................................................................................................... 203
customPaperSupport ........................................................................................................................................................ 203
customPaperTransverseSupport................................................................................................................................... 203
deviceResolution................................................................................................................................................................. 203
inRIPSeparationSupport................................................................................................................................................... 203
maxDeviceResolution........................................................................................................................................................ 203
maxPaperHeight ................................................................................................................................................................. 203
maxPaperHeightOffset ..................................................................................................................................................... 203
maxPaperWidth................................................................................................................................................................... 203
maxPaperWidthOffset....................................................................................................................................................... 203
minPaperHeight .................................................................................................................................................................. 204
minPaperHeightOffset ...................................................................................................................................................... 204
minPaperWidth.................................................................................................................................................................... 204
minPaperWidthOffset........................................................................................................................................................ 204
paperSizes.............................................................................................................................................................................. 204
postScriptLevel .................................................................................................................................................................... 204
printerType............................................................................................................................................................................ 204
typename............................................................................................................................................................................... 204
PrintFlattenerOptions.............................................................................................................................................................. 205
PrintFlattenerOptions properties.................................................................................................................................. 205
clipComplexRegions .......................................................................................................................................................... 205
convertStrokesToOutlines ............................................................................................................................................... 205
convertTextToOutlines ..................................................................................................................................................... 205
flatteningBalance................................................................................................................................................................ 205
gradientResolution............................................................................................................................................................. 205
overprint................................................................................................................................................................................. 205
rasterizationResolution..................................................................................................................................................... 205
typename............................................................................................................................................................................... 205
PrintFontOptions....................................................................................................................................................................... 206
PrintFontOptions properties........................................................................................................................................... 206
downloadFonts.................................................................................................................................................................... 206
fontSubstitution .................................................................................................................................................................. 206
typename............................................................................................................................................................................... 206
PrintJobOptions......................................................................................................................................................................... 207
PrintJobOptions properties............................................................................................................................................. 207
bitmapResolution ............................................................................................................................................................... 207
collate...................................................................................................................................................................................... 207
copies ...................................................................................................................................................................................... 207
designation ........................................................................................................................................................................... 207
file ............................................................................................................................................................................................. 207
name...........................................................................................................................
............................................................. 207
Adobe Illustrator CS2
JavaScript Scripting Reference 30
printArea ................................................................................................................................................................................ 207
printAsBitmap ...................................................................................................................................................................... 207
reversePages......................................................................................................................................................................... 207
typename............................................................................................................................................................................... 207
PrintOptions ................................................................................................................................................................................ 209
PrintOptions properties.................................................................................................................................................... 209
colorManagementOptions .............................................................................................................................................. 209
colorSeparationOptions ................................................................................................................................................... 209
coordinateOptions ............................................................................................................................................................. 209
flattenerOptions .................................................................................................................................................................. 209
flattenerPreset...................................................................................................................................................................... 209
fontOptions........................................................................................................................................................................... 209
jobOptions............................................................................................................................................................................. 209
pageMarksOptions ............................................................................................................................................................. 209
paperOptions ....................................................................................................................................................................... 209
postScriptOptions............................................................................................................................................................... 209
PPDName ............................................................................................................................................................................... 209
printerName.......................................................................................................................................................................... 209
printPreset ............................................................................................................................................................................. 209
typename............................................................................................................................................................................... 209
PrintPageMarksOptions .......................................................................................................................................................... 211
PrintPageMarksOptions properties .............................................................................................................................. 211
bleedOffsetRect................................................................................................................................................................... 211
colorBars................................................................................................................................................................................. 211
marksOffsetRect .................................................................................................................................................................. 211
pageInfoMarks ..................................................................................................................................................................... 211
pageMarksType ................................................................................................................................................................... 211
registrationMarks ................................................................................................................................................................ 211
trimMarks ............................................................................................................................................................................... 211
trimMarksWeight ................................................................................................................................................................ 211
typename............................................................................................................................................................................... 211
PrintPaperOptions .................................................................................................................................................................... 212
PrintPaperOptions properties ........................................................................................................................................ 212
height ...................................................................................................................................................................................... 212
name........................................................................................................................................................................................ 212
offset........................................................................................................................................................................................ 212
transverse............................................................................................................................................................................... 212
typename............................................................................................................................................................................... 212
width........................................................................................................................................................................................ 212
PrintPostScriptOptions............................................................................................................................................................ 213
PrintPostScriptOptions properties................................................................................................................................ 213
binaryPrinting....................................................................................................................................................................... 213
compatibleShading............................................................................................................................................................ 213
forceContinuousTone........................................................................................................................................................ 213
imageCompression ............................................................................................................................................................ 213
negativePrinting.................................................................................................................................................................. 213
postScriptLevel .................................................................................................................................................................... 213
shadingResolution.............................................................................................................................................................. 213
typename............................................................................................................................................................................... 213
RasterItem.................................................................................................................................................................................... 214
RasterItem properties..........................................................................................................
.............................................. 214
Adobe Illustrator CS2
JavaScript Scripting Reference 31
artworkKnockout ................................................................................................................................................................ 214
blendingMode ..................................................................................................................................................................... 214
boundingBox........................................................................................................................................................................ 214
contentVariable ................................................................................................................................................................... 214
controlBounds...................................................................................................................................................................... 214
editable................................................................................................................................................................................... 214
embedded ............................................................................................................................................................................. 214
file ............................................................................................................................................................................................. 214
geometricBounds ............................................................................................................................................................... 214
height ...................................................................................................................................................................................... 214
hidden..................................................................................................................................................................................... 214
imageColorSpace................................................................................................................................................................ 214
isIsolated ................................................................................................................................................................................ 214
layer.......................................................................................................................................................................................... 214
left............................................................................................................................................................................................. 214
locked...................................................................................................................................................................................... 214
matrix ...................................................................................................................................................................................... 214
name........................................................................................................................................................................................ 214
opacity .................................................................................................................................................................................... 214
parent...................................................................................................................................................................................... 214
position................................................................................................................................................................................... 214
selected................................................................................................................................................................................... 214
sliced........................................................................................................................................................................................ 214
status ....................................................................................................................................................................................... 215
tags........................................................................................................................................................................................... 215
top ............................................................................................................................................................................................ 215
typename............................................................................................................................................................................... 215
uRL............................................................................................................................................................................................ 215
visibilityVariable .................................................................................................................................................................. 215
visibleBounds ....................................................................................................................................................................... 215
width........................................................................................................................................................................................ 215
wrapInside ............................................................................................................................................................................. 215
wrapOffset............................................................................................................................................................................. 215
wrapped ................................................................................................................................................................................. 215
zOrderPosition ..................................................................................................................................................................... 215
RasterItem methods........................................................................................................................................................... 215
colorize.................................................................................................................................................................................... 215
duplicate ................................................................................................................................................................................ 215
move........................................................................................................................................................................................ 215
remove.................................................................................................................................................................................... 215
resize........................................................................................................................................................................................ 216
rotate ....................................................................................................................................................................................... 216
trace ......................................................................................................................................................................................... 216
transform................................................................................................................................................................................ 216
translate.................................................................................................................................................................................. 216
zOrder...................................................................................................................................................................................... 216
RasterItems .................................................................................................................................................................................. 217
RasterItems properties...................................................................................................................................................... 217
length ...................................................................................................................................................................................... 217
parent...................................................................................................................................................................................... 217
typename.......................................................................................................................
........................................................ 217
Adobe Illustrator CS2
JavaScript Scripting Reference 32
RasterItems methods......................................................................................................................................................... 217
add............................................................................................................................................................................................ 217
getByName............................................................................................................................................................................ 217
index ........................................................................................................................................................................................ 217
removeAll............................................................................................................................................................................... 217
RGBColor....................................................................................................................................................................................... 218
RGBColor properties .......................................................................................................................................................... 218
blue .......................................................................................................................................................................................... 218
green........................................................................................................................................................................................ 218
red............................................................................................................................................................................................. 218
typename............................................................................................................................................................................... 218
Screen............................................................................................................................................................................................ 219
Screen properties................................................................................................................................................................ 219
name........................................................................................................................................................................................ 219
screenInfo .............................................................................................................................................................................. 219
typename............................................................................................................................................................................... 219
ScreenInfo .................................................................................................................................................................................... 219
ScreenInfo properties........................................................................................................................................................ 219
angle........................................................................................................................................................................................ 219
defaultScreen ....................................................................................................................................................................... 219
frequency............................................................................................................................................................................... 219
typename............................................................................................................................................................................... 219
ScreenSpotFunction................................................................................................................................................................. 221
ScreenSpotFunction properties..................................................................................................................................... 221
name........................................................................................................................................................................................ 221
spotFunction......................................................................................................................................................................... 221
typename............................................................................................................................................................................... 221
Spot ................................................................................................................................................................................................ 222
Spot properties .................................................................................................................................................................... 222
color ......................................................................................................................................................................................... 222
colorType ............................................................................................................................................................................... 222
name........................................................................................................................................................................................ 222
parent...................................................................................................................................................................................... 222
typename............................................................................................................................................................................... 222
Spot methods....................................................................................................................................................................... 222
remove.................................................................................................................................................................................... 222
SpotColor ..................................................................................................................................................................................... 223
SpotColor properties ......................................................................................................................................................... 223
spot .......................................................................................................................................................................................... 223
tint ............................................................................................................................................................................................ 223
typename............................................................................................................................................................................... 223
Spots .............................................................................................................................................................................................. 224
Spots properties .................................................................................................................................................................. 224
length ...................................................................................................................................................................................... 224
parent...................................................................................................................................................................................... 224
typename............................................................................................................................................................................... 224
Spots methods ..................................................................................................................................................................... 224
add............................................................................................................................................................................................ 224
getByName............................................................................................................................................................................ 224
index ........................................................................................................................................................................................ 224
removeAll......................................................................................................................
......................................................... 224
Adobe Illustrator CS2
JavaScript Scripting Reference 33
Story ............................................................................................................................................................................................... 226
Story properties ................................................................................................................................................................... 226
characters............................................................................................................................................................................... 226
insertionPoints..................................................................................................................................................................... 226
length ...................................................................................................................................................................................... 226
lines.......................................................................................................................................................................................... 226
paragraphs ............................................................................................................................................................................ 226
parent...................................................................................................................................................................................... 226
textFrames............................................................................................................................................................................. 226
textRange............................................................................................................................................................................... 226
textRanges............................................................................................................................................................................. 226
textSelection......................................................................................................................................................................... 226
typename............................................................................................................................................................................... 226
words....................................................................................................................................................................................... 226
Stories............................................................................................................................................................................................ 228
Stories properties................................................................................................................................................................ 228
length ...................................................................................................................................................................................... 228
parent...................................................................................................................................................................................... 228
typename............................................................................................................................................................................... 228
Stories methods................................................................................................................................................................... 228
index ........................................................................................................................................................................................ 228
Swatch........................................................................................................................................................................................... 229
Swatch properties............................................................................................................................................................... 229
color ......................................................................................................................................................................................... 229
name........................................................................................................................................................................................ 229
parent...................................................................................................................................................................................... 229
typename............................................................................................................................................................................... 229
Swatch methods.................................................................................................................................................................. 229
remove.................................................................................................................................................................................... 229
Swatches....................................................................................................................................................................................... 230
Swatches properties .......................................................................................................................................................... 230
length ...................................................................................................................................................................................... 230
parent...................................................................................................................................................................................... 230
typename............................................................................................................................................................................... 230
Swatches methods ............................................................................................................................................................. 230
add............................................................................................................................................................................................ 230
getByName............................................................................................................................................................................ 230
index ........................................................................................................................................................................................ 230
removeAll............................................................................................................................................................................... 230
Symbol .......................................................................................................................................................................................... 231
Symbol properties .............................................................................................................................................................. 231
name........................................................................................................................................................................................ 231
parent...................................................................................................................................................................................... 231
typename............................................................................................................................................................................... 231
Symbol methods ................................................................................................................................................................. 231
duplicate ................................................................................................................................................................................ 231
remove.................................................................................................................................................................................... 231
Symbols......................................................................................................................................................................................... 232
Symbols properties ............................................................................................................................................................ 232
length ...................................................................................................................................................................................... 232
parent.........................................................................................................................
............................................................. 232
Adobe Illustrator CS2
JavaScript Scripting Reference 34
typename............................................................................................................................................................................... 232
Symbols methods ............................................................................................................................................................... 232
add............................................................................................................................................................................................ 232
index ........................................................................................................................................................................................ 232
getByName............................................................................................................................................................................ 232
removeAll............................................................................................................................................................................... 232
SymbolItem ................................................................................................................................................................................. 234
SymbolItem properties ..................................................................................................................................................... 234
artworkKnockout ................................................................................................................................................................ 234
blendingMode ..................................................................................................................................................................... 234
controlBounds...................................................................................................................................................................... 234
editable................................................................................................................................................................................... 234
geometricBounds ............................................................................................................................................................... 234
height ...................................................................................................................................................................................... 234
hidden..................................................................................................................................................................................... 234
isIsolated ................................................................................................................................................................................ 234
layer.......................................................................................................................................................................................... 234
left............................................................................................................................................................................................. 234
locked...................................................................................................................................................................................... 234
name........................................................................................................................................................................................ 234
opacity .................................................................................................................................................................................... 234
parent...................................................................................................................................................................................... 234
position................................................................................................................................................................................... 234
selected................................................................................................................................................................................... 234
sliced........................................................................................................................................................................................ 234
symbol..................................................................................................................................................................................... 234
tags........................................................................................................................................................................................... 234
top ............................................................................................................................................................................................ 234
typename............................................................................................................................................................................... 234
uRL............................................................................................................................................................................................ 234
visibilityVariable .................................................................................................................................................................. 234
visibleBounds ....................................................................................................................................................................... 235
width........................................................................................................................................................................................ 235
wrapInside ............................................................................................................................................................................. 235
wrapOffset............................................................................................................................................................................. 235
wrapped ................................................................................................................................................................................. 235
zOrderPosition ..................................................................................................................................................................... 235
SymbolItem methods........................................................................................................................................................ 235
duplicate ................................................................................................................................................................................ 235
move........................................................................................................................................................................................ 235
remove.................................................................................................................................................................................... 235
resize........................................................................................................................................................................................ 235
rotate ....................................................................................................................................................................................... 235
transform................................................................................................................................................................................ 236
translate.................................................................................................................................................................................. 236
zOrder...................................................................................................................................................................................... 236
SymbolItems ............................................................................................................................................................................... 237
SymbolItems properties ................................................................................................................................................... 237
length ...................................................................................................................................................................................... 237
parent...................................................................................................................................................................................... 237
typename.......................................................................................................................
........................................................ 237
Adobe Illustrator CS2
JavaScript Scripting Reference 35
SymbolItems methods ...................................................................................................................................................... 237
add............................................................................................................................................................................................ 237
getByName............................................................................................................................................................................ 237
index ........................................................................................................................................................................................ 237
removeAll............................................................................................................................................................................... 237
TabStopInfo................................................................................................................................................................................. 238
TabStopInfo properties..................................................................................................................................................... 238
alignment............................................................................................................................................................................... 238
decimalCharacter................................................................................................................................................................ 238
leader....................................................................................................................................................................................... 238
position................................................................................................................................................................................... 238
typename............................................................................................................................................................................... 238
Tag .................................................................................................................................................................................................. 239
Tag properties ...................................................................................................................................................................... 239
name........................................................................................................................................................................................ 239
parent...................................................................................................................................................................................... 239
typename............................................................................................................................................................................... 239
value ........................................................................................................................................................................................ 239
Tag methods......................................................................................................................................................................... 239
remove.................................................................................................................................................................................... 239
Tags ................................................................................................................................................................................................ 240
Tags properties .................................................................................................................................................................... 240
length ...................................................................................................................................................................................... 240
parent...................................................................................................................................................................................... 240
typename............................................................................................................................................................................... 240
Tags methods ....................................................................................................................................................................... 240
add............................................................................................................................................................................................ 240
getByName............................................................................................................................................................................ 240
index ........................................................................................................................................................................................ 240
removeAll............................................................................................................................................................................... 240
TextFont........................................................................................................................................................................................ 241
TextFont properties............................................................................................................................................................ 241
family....................................................................................................................................................................................... 241
name........................................................................................................................................................................................ 241
parent...................................................................................................................................................................................... 241
style.......................................................................................................................................................................................... 241
typename............................................................................................................................................................................... 241
TextFonts...................................................................................................................................................................................... 242
TextFonts properties.......................................................................................................................................................... 242
length ...................................................................................................................................................................................... 242
parent...................................................................................................................................................................................... 242
typename............................................................................................................................................................................... 242
TextFonts methods ............................................................................................................................................................ 242
index ........................................................................................................................................................................................ 242
getByName............................................................................................................................................................................ 242
TextFrame .................................................................................................................................................................................... 243
TextFrame properties ........................................................................................................................................................ 243
anchor ..................................................................................................................................................................................... 243
artworkKnockout ................................................................................................................................................................ 243
blendingMode ..................................................................................................................................................................... 243
characters.....................................................................................................................
.......................................................... 243
Adobe Illustrator CS2
JavaScript Scripting Reference 36
columnCount........................................................................................................................................................................ 243
columnGutter ....................................................................................................................................................................... 243
contents.................................................................................................................................................................................. 243
contentVariable ................................................................................................................................................................... 243
controlBounds...................................................................................................................................................................... 243
editable................................................................................................................................................................................... 243
endTValue.............................................................................................................................................................................. 243
flowLinksHorizontally........................................................................................................................................................ 243
geometricBounds ............................................................................................................................................................... 243
height ...................................................................................................................................................................................... 243
hidden..................................................................................................................................................................................... 243
insertionPoints..................................................................................................................................................................... 243
isIsolated ................................................................................................................................................................................ 243
kind........................................................................................................................................................................................... 243
layer.......................................................................................................................................................................................... 243
left............................................................................................................................................................................................. 243
lines.......................................................................................................................................................................................... 243
locked...................................................................................................................................................................................... 243
matrix ...................................................................................................................................................................................... 244
name........................................................................................................................................................................................ 244
nextFrame.............................................................................................................................................................................. 244
opacity .................................................................................................................................................................................... 244
opticalAlignment ................................................................................................................................................................ 244
orientation............................................................................................................................................................................. 244
paragraphs ............................................................................................................................................................................ 244
parent...................................................................................................................................................................................... 244
position................................................................................................................................................................................... 244
previousFrame ..................................................................................................................................................................... 244
rowCount ............................................................................................................................................................................... 244
rowGutter............................................................................................................................................................................... 244
selected................................................................................................................................................................................... 244
sliced........................................................................................................................................................................................ 244
spacing.................................................................................................................................................................................... 244
startTValue............................................................................................................................................................................. 244
story ......................................................................................................................................................................................... 244
tags........................................................................................................................................................................................... 244
textPath .................................................................................................................................................................................. 244
textRange............................................................................................................................................................................... 244
textRanges............................................................................................................................................................................. 244
textSelection......................................................................................................................................................................... 244
top ............................................................................................................................................................................................ 244
typename............................................................................................................................................................................... 244
uRL............................................................................................................................................................................................ 244
visibilityVariable .................................................................................................................................................................. 244
visibleBounds ....................................................................................................................................................................... 245
width........................................................................................................................................................................................ 245
words....................................................................................................................................................................................... 245
wrapInside ............................................................................................................................................................................. 245
wrapOffset............................................................................................................................................................................. 245
wrapped ................................................................................................................................................................................. 245
zOrderPosition .................................................................................................................
.................................................... 245
Adobe Illustrator CS2
JavaScript Scripting Reference 37
TextFrame methods........................................................................................................................................................... 245
createOutline........................................................................................................................................................................ 245
duplicate ................................................................................................................................................................................ 245
move........................................................................................................................................................................................ 245
remove.................................................................................................................................................................................... 245
resize........................................................................................................................................................................................ 245
rotate ....................................................................................................................................................................................... 245
transform................................................................................................................................................................................ 246
translate.................................................................................................................................................................................. 246
zOrder...................................................................................................................................................................................... 246
TextFrames .................................................................................................................................................................................. 247
TextFrames properties ...................................................................................................................................................... 247
length ...................................................................................................................................................................................... 247
parent...................................................................................................................................................................................... 247
typename............................................................................................................................................................................... 247
TextFrames methods ......................................................................................................................................................... 247
add............................................................................................................................................................................................ 247
areaText.................................................................................................................................................................................. 247
getByName............................................................................................................................................................................ 247
index ........................................................................................................................................................................................ 247
pathText ................................................................................................................................................................................. 247
pointText................................................................................................................................................................................ 247
removeAll............................................................................................................................................................................... 247
TextPath........................................................................................................................................................................................ 249
TextPath properties............................................................................................................................................................ 249
area........................................................................................................................................................................................... 249
blendingMode ..................................................................................................................................................................... 249
clipping................................................................................................................................................................................... 249
editable................................................................................................................................................................................... 249
evenodd ................................................................................................................................................................................. 249
fillColor.................................................................................................................................................................................... 249
filled ......................................................................................................................................................................................... 249
fillOverprint ........................................................................................................................................................................... 249
guides...................................................................................................................................................................................... 249
height ...................................................................................................................................................................................... 249
left............................................................................................................................................................................................. 249
note.......................................................................................................................................................................................... 249
opacity .................................................................................................................................................................................... 249
parent...................................................................................................................................................................................... 249
pathPoints ............................................................................................................................................................................. 249
polarity.................................................................................................................................................................................... 249
position................................................................................................................................................................................... 249
resolution............................................................................................................................................................................... 249
selectedPathPoints............................................................................................................................................................. 249
strokeCap ............................................................................................................................................................................... 249
strokeColor ............................................................................................................................................................................ 249
stroked .................................................................................................................................................................................... 249
strokeDashes ........................................................................................................................................................................ 250
strokeDashOffset................................................................................................................................................................. 250
strokeJoin............................................................................................................................................................................... 250
strokeMiterLimit ...............................................................................................................
................................................... 250
Adobe Illustrator CS2
JavaScript Scripting Reference 38
strokeOverprint.................................................................................................................................................................... 250
strokeWidth........................................................................................................................................................................... 250
top ............................................................................................................................................................................................ 250
typename............................................................................................................................................................................... 250
width........................................................................................................................................................................................ 250
TextPath methods .............................................................................................................................................................. 250
setEntirePath ........................................................................................................................................................................ 250
TextRange .................................................................................................................................................................................... 251
TextRange properties ........................................................................................................................................................ 251
characterAttributes ............................................................................................................................................................ 251
characterOffset .................................................................................................................................................................... 251
characters............................................................................................................................................................................... 251
characterStyles..................................................................................................................................................................... 251
contents.................................................................................................................................................................................. 251
insertionPoints..................................................................................................................................................................... 251
kerning.................................................................................................................................................................................... 251
length ...................................................................................................................................................................................... 251
lines.......................................................................................................................................................................................... 251
paragraphAttributes .......................................................................................................................................................... 251
paragraphs ............................................................................................................................................................................ 251
paragraphStyles................................................................................................................................................................... 251
parent...................................................................................................................................................................................... 251
story ......................................................................................................................................................................................... 251
textRanges............................................................................................................................................................................. 251
textSelection......................................................................................................................................................................... 251
typename............................................................................................................................................................................... 251
words....................................................................................................................................................................................... 251
TextRange methods........................................................................................................................................................... 252
changeCaseTo...................................................................................................................................................................... 252
deSelect.................................................................................................................................................................................. 252
duplicate ................................................................................................................................................................................ 252
move........................................................................................................................................................................................ 252
remove.................................................................................................................................................................................... 252
select........................................................................................................................................................................................ 252
TextRanges .................................................................................................................................................................................. 253
TextRanges properties ...................................................................................................................................................... 253
length ...................................................................................................................................................................................... 253
parent...................................................................................................................................................................................... 253
typename............................................................................................................................................................................... 253
TextRanges methods......................................................................................................................................................... 253
index ........................................................................................................................................................................................ 253
removeAll............................................................................................................................................................................... 253
TracingObject ............................................................................................................................................................................. 254
TracingObject properties ................................................................................................................................................. 254
anchorCount......................................................................................................................................................................... 254
areaCount .............................................................................................................................................................................. 254
imageResolution ................................................................................................................................................................. 254
parent...................................................................................................................................................................................... 254
pathCount.............................................................................................................................................................................. 254
sourceArt................................................................................................................................................................................ 254
tracingOptions .................................................................................................................
.................................................... 254
Adobe Illustrator CS2
JavaScript Scripting Reference 39
typename............................................................................................................................................................................... 254
usedColorCount .................................................................................................................................................................. 254
TracingObject methods.................................................................................................................................................... 255
expandTracing ..................................................................................................................................................................... 255
releaseTracing ...................................................................................................................................................................... 255
TracingOptions........................................................................................................................................................................... 256
TracingOptions properties .............................................................................................................................................. 256
cornerAngle .......................................................................................................................................................................... 256
fills............................................................................................................................................................................................. 256
livePaintOutput ................................................................................................................................................................... 256
maxColors.............................................................................................................................................................................. 256
maxStrokeWeight ............................................................................................................................................................... 256
minArea .................................................................................................................................................................................. 256
minStrokeLength ................................................................................................................................................................ 256
outputToSwatches ............................................................................................................................................................. 256
palette ..................................................................................................................................................................................... 256
parent...................................................................................................................................................................................... 256
pathFitting............................................................................................................................................................................. 256
preprocessBlur ..................................................................................................................................................................... 257
preset....................................................................................................................................................................................... 257
resample................................................................................................................................................................................. 257
resampleResolution ........................................................................................................................................................... 257
strokes..................................................................................................................................................................................... 257
threshold................................................................................................................................................................................ 257
tracingMode ......................................................................................................................................................................... 257
typename............................................................................................................................................................................... 257
viewRaster ............................................................................................................................................................................. 257
viewVector............................................................................................................................................................................. 257
TracingOptions methods ................................................................................................................................................. 257
loadFromPreset ................................................................................................................................................................... 257
storeToPreset........................................................................................................................................................................ 257
Variable ......................................................................................................................................................................................... 258
Variable properties ............................................................................................................................................................. 258
kind........................................................................................................................................................................................... 258
name........................................................................................................................................................................................ 258
pageItems.............................................................................................................................................................................. 258
parent...................................................................................................................................................................................... 258
typename............................................................................................................................................................................... 258
Variable methods................................................................................................................................................................ 258
remove.................................................................................................................................................................................... 258
Variables ....................................................................................................................................................................................... 259
Variables properties ........................................................................................................................................................... 259
length ...................................................................................................................................................................................... 259
parent...................................................................................................................................................................................... 259
typename............................................................................................................................................................................... 259
Variables methods .............................................................................................................................................................. 259
add............................................................................................................................................................................................ 259
getByName............................................................................................................................................................................ 259
index ........................................................................................................................................................................................ 259
removeAll............................................................................................................................................................................... 259
View...........................................................................................................................
..................................................................... 260
Adobe Illustrator CS2
JavaScript Scripting Reference 40
View properties.................................................................................................................................................................... 260
bounds.................................................................................................................................................................................... 260
centerPoint............................................................................................................................................................................ 260
parent...................................................................................................................................................................................... 260
screenMode .......................................................................................................................................................................... 260
typename............................................................................................................................................................................... 260
zoom........................................................................................................................................................................................ 260
Views.............................................................................................................................................................................................. 261
Views properties.................................................................................................................................................................. 261
length ...................................................................................................................................................................................... 261
parent...................................................................................................................................................................................... 261
typename............................................................................................................................................................................... 261
Views methods..................................................................................................................................................................... 261
index ........................................................................................................................................................................................ 261
Words............................................................................................................................................................................................. 262
Words properties................................................................................................................................................................. 262
length ...................................................................................................................................................................................... 262
parent...................................................................................................................................................................................... 262
typename............................................................................................................................................................................... 262
Words methods ................................................................................................................................................................... 262
add............................................................................................................................................................................................ 262
addBefore .............................................................................................................................................................................. 262
index ........................................................................................................................................................................................ 262
removeAll............................................................................................................................................................................... 262
6 File and Folder Object Reference ...........................................................................................264
Overview ...................................................................................................................................................................................... 264
File Object .................................................................................................................................................................................... 264
File object constructors .................................................................................................................................................... 264
File class properties............................................................................................................................................................ 265
fs................................................................................................................................................................................................ 265
File class functions.............................................................................................................................................................. 265
decode .................................................................................................................................................................................... 265
encode .................................................................................................................................................................................... 265
isEncodingAvailable........................................................................................................................................................... 265
openDialog............................................................................................................................................................................ 266
saveDialog ............................................................................................................................................................................. 266
File object properties......................................................................................................................................................... 267
absoluteURI ........................................................................................................................................................................... 267
alias........................................................................................................................................................................................... 267
created .................................................................................................................................................................................... 267
creator..................................................................................................................................................................................... 267
encoding ................................................................................................................................................................................ 267
eof............................................................................................................................................................................................. 267
error.......................................................................................................................................................................................... 267
exists ........................................................................................................................................................................................ 267
fsName .................................................................................................................................................................................... 267
hidden..................................................................................................................................................................................... 267
length ...................................................................................................................................................................................... 267
lineFeed.................................................................................................................................................................................. 267
modified ................................................................................................................................................................................. 267
Adobe Illustrator CS2
JavaScript Scripting Reference 41
name........................................................................................................................................................................................ 267
parent...................................................................................................................................................................................... 267
path.......................................................................................................................................................................................... 268
readonly.................................................................................................................................................................................. 268
relativeURI.............................................................................................................................................................................. 268
type .......................................................................................................................................................................................... 268
File object functions........................................................................................................................................................... 268
close......................................................................................................................................................................................... 268
copy.......................................................................................................................................................................................... 268
createAlias ............................................................................................................................................................................. 268
execute ................................................................................................................................................................................... 268
getRelativeURI...................................................................................................................................................................... 268
open......................................................................................................................................................................................... 269
openDlg.................................................................................................................................................................................. 270
read .......................................................................................................................................................................................... 270
readch ..................................................................................................................................................................................... 270
readln ...................................................................................................................................................................................... 270
remove.................................................................................................................................................................................... 270
rename.................................................................................................................................................................................... 271
resolve..................................................................................................................................................................................... 271
saveDlg ................................................................................................................................................................................... 271
seek .......................................................................................................................................................................................... 271
tell............................................................................................................................................................................................. 271
write......................................................................................................................................................................................... 272
writeln ..................................................................................................................................................................................... 272
Folder Object ............................................................................................................................................................................. 273
Folder object constructors............................................................................................................................................... 273
Folder class properties ...................................................................................................................................................... 273
appData.................................................................................................................................................................................. 273
commonFiles ........................................................................................................................................................................ 273
current..................................................................................................................................................................................... 273
fs................................................................................................................................................................................................ 273
myDocuments...................................................................................................................................................................... 273
startup..................................................................................................................................................................................... 273
system ..................................................................................................................................................................................... 274
temp......................................................................................................................................................................................... 274
trash ......................................................................................................................................................................................... 274
userData ................................................................................................................................................................................. 274
Folder class functions ........................................................................................................................................................ 274
decode .................................................................................................................................................................................... 274
encode .................................................................................................................................................................................... 274
isEncodingAvailable........................................................................................................................................................... 274
selectDialog........................................................................................................................................................................... 275
Folder object properties................................................................................................................................................... 275
absoluteURI ........................................................................................................................................................................... 275
alias........................................................................................................................................................................................... 275
created .................................................................................................................................................................................... 275
error.......................................................................................................................................................................................... 275
exists ........................................................................................................................................................................................ 275
fsName .................................................................................................................................................................................... 275
modified .......................................................................................................................
.......................................................... 275
Adobe Illustrator CS2
JavaScript Scripting Reference 42
name........................................................................................................................................................................................ 275
parent...................................................................................................................................................................................... 275
path.......................................................................................................................................................................................... 275
relativeURI.............................................................................................................................................................................. 275
Folder object functions..................................................................................................................................................... 276
create....................................................................................................................................................................................... 276
execute ................................................................................................................................................................................... 276
getFiles.................................................................................................................................................................................... 276
getRelativeURI...................................................................................................................................................................... 276
remove.................................................................................................................................................................................... 276
rename.................................................................................................................................................................................... 276
resolve..................................................................................................................................................................................... 276
selectDlg................................................................................................................................................................................. 277
File and Folder Error Messages ............................................................................................................................................ 278
File and Folder Supported Encoding Names .................................................................................................................. 279
Additional encodings ........................................................................................................................................................ 279
7 Scripting Constants .................................................................................................................281
AlternateGlyphsForm ........................................................................................................................................................ 281
AutoKernType ...................................................................................................................................................................... 281
AutoLeadingType ............................................................................................................................................................... 281
BaselineDirectionType ...................................................................................................................................................... 281
BlendAnimationType......................................................................................................................................................... 281
BlendModes .......................................................................................................................................................................... 281
BurasagariTypeEnum......................................................................................................................................................... 281
CaseChangeType ................................................................................................................................................................ 281
ColorConversion.................................................................................................................................................................. 282
ColorDestination ................................................................................................................................................................. 282
ColorDitherMethod............................................................................................................................................................ 282
ColorModel............................................................................................................................................................................ 282
ColorProfile............................................................................................................................................................................ 282
ColorReductionMethod.................................................................................................................................................... 282
ColorType............................................................................................................................................................................... 282
Compatibility ........................................................................................................................................................................ 282
CompressionQuality .......................................................................................................................................................... 283
CropOptions.......................................................................................................................................................................... 283
DocumentColorSpace ....................................................................................................................................................... 283
DocumentType .................................................................................................................................................................... 283
DownsampleMethod......................................................................................................................................................... 283
ElementPlacement ............................................................................................................................................................. 283
EPSPostScriptLevelEnum ................................................................................................................................................. 283
EPSPreview............................................................................................................................................................................ 283
ExportType ............................................................................................................................................................................ 284
FigureStyleType................................................................................................................................................................... 284
FlashExportStyle.................................................................................................................................................................. 284
FlashImageFormat.............................................................................................................................................................. 284
FlashJPEGMethod ............................................................................................................................................................... 284
FontBaselineOption ........................................................................................................................................................... 284
FontCapsOption .................................................................................................................................................................. 284
FontOpenTypePositionOption....................................................................................................................................... 284
FontSubstitutionPolicy ..................................................................................................................................................... 284
Adobe Illustrator CS2
JavaScript Scripting Reference 43
GradientType........................................................................................................................................................................ 284
ImageColorSpace................................................................................................................................................................ 284
InkPrintStatus ....................................................................................................................................................................... 284
InkType ................................................................................................................................................................................... 284
JavaScriptExecutionMode ............................................................................................................................................... 284
Justification ........................................................................................................................................................................... 285
KinsokuOrderEnum ............................................................................................................................................................ 285
KnockoutState...................................................................................................................................................................... 285
LanguageType ..................................................................................................................................................................... 285
LayerOrderType................................................................................................................................................................... 285
MonochromeCompression ............................................................................................................................................. 285
OutputFlattening ................................................................................................................................................................ 286
PageMarksTypes.................................................................................................................................................................. 286
PathPointSelection............................................................................................................................................................. 286
PDFBoxType.......................................................................................................................................................................... 286
PDFChangesAllowedEnum ............................................................................................................................................. 286
PDFCompatibility................................................................................................................................................................ 286
PDFOverprint........................................................................................................................................................................ 286
PDFPrintAllowedEnum ..................................................................................................................................................... 286
PDFTrimMarkWeight ......................................................................................................................................................... 286
PDFXStandard ...................................................................................................................................................................... 286
PhotoshopCompatibility .................................................................................................................................................. 286
PointType............................................................................................................................................................................... 286
PolarityValues....................................................................................................................................................................... 287
PostScriptImageCompressionType .............................................................................................................................. 287
PrintArtworkDesignation ................................................................................................................................................. 287
PrintColorIntent................................................................................................................................................................... 287
PrintColorProfile.................................................................................................................................................................. 287
PrintColorSeparationMode ............................................................................................................................................. 287
PrinterColorMode ............................................................................................................................................................... 287
PrinterPostScriptLevelEnum ........................................................................................................................................... 287
PrinterTypeEnum ................................................................................................................................................................ 287
PrintFontDownloadMode................................................................................................................................................ 287
PrintingBounds .................................................................................................................................................................... 287
PrintOrientation................................................................................................................................................................... 287
PrintPosition ......................................................................................................................................................................... 287
PrintTiling............................................................................................................................................................................... 287
RasterLinkState .................................................................................................................................................................... 288
RulerUnits .............................................................................................................................................................................. 288
SaveOptions.......................................................................................................................................................................... 288
ScreenMode.......................................................................................................................................................................... 288
StrokeCap............................................................................................................................................................................... 288
StrokeJoin .............................................................................................................................................................................. 288
StyleRunAlignmentType .................................................................................................................................................. 288
SVGCSSPropertyLocation................................................................................................................................................. 288
SVGDocumentEncoding................................................................................................................................................... 288
SVGDTDVersion ................................................................................................................................................................... 288
SVGFontSubsetting ............................................................................................................................................................ 288
SVGFontType ........................................................................................................................................................................ 288
TabStopAlignment ............................................................................................................................................................. 289
TextOrientation................................................................................................................
.................................................... 289
Adobe Illustrator CS2
JavaScript Scripting Reference 44
TextType................................................................................................................................................................................. 289
TracingModeType............................................................................................................................................................... 289
Transformation .................................................................................................................................................................... 289
TrappingType ....................................................................................................................................................................... 289
UserInteractionLevel.......................................................................................................................................................... 289
VariableKind.......................................................................................................................................................................... 289
ViewRasterType ................................................................................................................................................................... 289
ViewVectorType................................................................................................................................................................... 289
WariChuJustificationType ................................................................................................................................................ 289
ZOrderMethod ..................................................................................................................................................................... 290
8 ExtendScript Tools and Features............................................................................................ 291
The ExtendScript Toolkit......................................................................................................................................................... 291
Configuring the Toolkit window ................................................................................................................................... 292
Selecting a debugging target ........................................................................................................................................ 293
Selecting scripts................................................................................................................................................................... 294
Tracking data ........................................................................................................................................................................ 294
The JavaScript console ..................................................................................................................................................... 295
The call stack ........................................................................................................................................................................ 296
The Script Editor .................................................................................................................................................................. 297
Mouse navigation and selection ............................................................................................................................. 297
Keyboard navigation and selection ....................................................................................................................... 297
Syntax checking ............................................................................................................................................................ 298
Debugging in the Toolkit ................................................................................................................................................. 298
Evaluation in help tips................................................................................................................................................. 298
Controlling code execution ...................................................................................................................................... 298
Visual indication of execution states ..................................................................................................................... 299
Setting breakpoints .................................................................................................................................................... 300
Profiling .................................................................................................................................................................................. 301
Dollar ($) Object ........................................................................................................................................................................ 303
Dollar ($) object properties ............................................................................................................................................. 303
build......................................................................................................................................................................................... 303
buildDate ............................................................................................................................................................................... 303
error.......................................................................................................................................................................................... 303
flags.......................................................................................................................................................................................... 303
global....................................................................................................................................................................................... 303
level.......................................................................................................................................................................................... 303
locale ....................................................................................................................................................................................... 303
localize .................................................................................................................................................................................... 304
memCache ............................................................................................................................................................................ 304
objects..................................................................................................................................................................................... 304
os............................................................................................................................................................................................... 304
screens .................................................................................................................................................................................... 304
strict ......................................................................................................................................................................................... 304
version..................................................................................................................................................................................... 304
Dollar ($) object functions ............................................................................................................................................... 304
about ....................................................................................................................................................................................... 304
bp.............................................................................................................................................................................................. 304
clearbp .................................................................................................................................................................................... 304
gc .............................................................................................................................................................................................. 304
getenv ..................................................................................................................................................................................... 304
Adobe Illustrator CS2
JavaScript Scripting Reference 45
list.............................................................................................................................................................................................. 304
setbp........................................................................................................................................................................................ 305
sleep......................................................................................................................................................................................... 305
summary................................................................................................................................................................................. 305
write......................................................................................................................................................................................... 305
writeln ..................................................................................................................................................................................... 305
Object statistics ............................................................................................................................................................. 305
ExtendScript Reflection Interface ........................................................................................................................................ 307
Reflection Object................................................................................................................................................................. 307
Reflection object properties ..................................................................................................................................... 307
description............................................................................................................................................................................. 307
help .......................................................................................................................................................................................... 307
methods ................................................................................................................................................................................. 307
name........................................................................................................................................................................................ 307
properties............................................................................................................................................................................... 307
Reflection object functions ....................................................................................................................................... 307
find ........................................................................................................................................................................................... 307
ReflectionInfo Object......................................................................................................................................................... 308
ReflectionInfo object properties ............................................................................................................................. 308
arguments ............................................................................................................................................................................. 308
dataType................................................................................................................................................................................. 308
defaultValue.......................................................................................................................................................................... 308
description............................................................................................................................................................................. 308
help .......................................................................................................................................................................................... 309
isCollection............................................................................................................................................................................ 309
max........................................................................................................................................................................................... 309
min............................................................................................................................................................................................ 309
name........................................................................................................................................................................................ 309
type .......................................................................................................................................................................................... 309
Localizing ExtendScript Strings............................................................................................................................................ 310
Variable values in localized strings ............................................................................................................................... 310
Enabling automatic localization .................................................................................................................................... 310
Locale names........................................................................................................................................................................ 311
Testing localization ............................................................................................................................................................ 312
Global localize function .................................................................................................................................................... 313
localize .................................................................................................................................................................................... 313
User Notification Helper Functions..................................................................................................................................... 314
Global alert function .......................................................................................................................................................... 314
alert .......................................................................................................................................................................................... 314
Global confirm function.................................................................................................................................................... 315
confirm.................................................................................................................................................................................... 315
Global prompt function.................................................................................................................................................... 315
prompt.................................................................................................................................................................................... 315
Specifying Measurement Values ........................................................................................................................................ 317
UnitValue Object ................................................................................................................................................................. 317
UnitValue object constructor ................................................................................................................................... 317
UnitValue object properties...................................................................................................................................... 318
baseUnit ................................................................................................................................................................................. 318
type .......................................................................................................................................................................................... 318
value ........................................................................................................................................................................................ 318
UnitValue object functions........................................................................................................................................ 318
Adobe Illustrator CS2
JavaScript Scripting Reference 46
as ............................................................................................................................................................................................... 318
convert.................................................................................................................................................................................... 318
Converting pixel and percentage values ................................................................................................................... 318
Computing with unit values ........................................................................................................................................... 319
Modular Programming Support .......................................................................................................................................... 321
Preprocessor directives..................................................................................................................................................... 321
#engine name ....................................................................................................................................................................... 321
#include file ........................................................................................................................................................................... 321
#includepath path .............................................................................................................................................................. 322
#script name .......................................................................................................................................................................... 322
#strict on................................................................................................................................................................................. 322
#target name ........................................................................................................................................................................ 322
Importing and exporting between scripts................................................................................................................. 322
Operator Overloading ............................................................................................................................................................ 324
Application and Namespace Specifiers............................................................................................................................. 325
Application specifiers ........................................................................................................................................................ 325
Namespace specifiers ........................................................................................................................................................ 326
Script Locations and Checking Application Installation ............................................................................................. 326
Index .........................................................................................................................................328
1
Introduction
This reference describes the objects and commands in the Adobe® Illustrator® CS2 JavaScript type library.
It contains the following sections:
● This introduction, which describes scripting support in Adobe Illustrator CS2, and lists changes to the
JavaScript interface since the previous release.
● Scripting Basics, which introduces the fundamental concepts of scripting with JavaScript. If you are
new to scripting, be sure to read this chapter.
● Scripting Illustrator, which describes the Illustrator document object model and provides an overview
of how to use JavaScript to program Adobe Illustrator CS2.
● Using File and Folder Objects, which describes ExtendScript’s platform-independent representation of
files and folders.
● JavaScript Object Reference, which provides a complete reference for all Illustrator DOM objects and
commands.
● File and Folder Object Reference, which provides a complete reference for the ExtendScript File and
Folder classes.
● Scripting Constants, which lists all enumerations used in the Illustrator type library.
● ExtendScript Tools and Features, which describes ExtendScript’s debugging tools and programming
utilities.
What is scripting?
A script is a series of commands that tells Illustrator to perform a series of actions. These actions can be
simple, and affect only a single, selected object in the current document; or complex, and affect all of the
objects in all of your Illustrator documents. The actions might involve only Illustrator, or they might
involve other applications, such as word processors, spreadsheets, and database management programs.
Many of the tasks you can perform with the Illustrator tools, menus, palettes, and dialog boxes can be
performed by a script (a notable exception is third-party plug-ins, which cannot be scripted at this time).
We naturally think of scripting as a way to automate repetitive tasks, but it can also be a creative tool. You
can use scripts for creative tasks that would be too difficult or time consuming to do manually. For
example, you could write a script to systematically create a series of objects, modifying the new objects’
position, stroke, and fill properties along the way. You could also write a script that accessed built-in
transformation matrix functions to stretch, scale and distort a series of objects. Without scripting, you’ll
likely miss out on the creative potential of such labor-intensive techniques.
Scripting isn’t just for computer programmers—it’s for everybody. You don’t need a degree in computer
science or mathematics to write scripts that can automate a wide variety of common tasks. If you can read
this text, you can write scripts.
The language you use to write scripts depends on the operating system of the platform you’re using:
AppleScript for Mac OS® ; Visual Basic for Windows® ; JavaScript for either platform. Each of these languages
is described in a separate manual.
47
Adobe Illustrator CS2
JavaScript Scripting Reference Introduction 48
Why use scripting?
Graphic design is a field characterized by creativity, but aspects of the actual work of illustration and page
layout are anything but creative. When you think about the work that you do, chances are good you’ll find
that you spend most of your time doing the same or similar production tasks, over and over again. In fact,
you’ll probably notice that the time you spend placing and replacing images, correcting errors in text, and
preparing files for printing at an image setting service provider often reduce the time you have available
for doing creative work.
Wouldn’t it be great if you had an assistant—one that wouldn’t mind doing some or all of the boring,
repetitive tasks for you? With that kind of help, you’d have more time to concentrate on the creative
aspects of your work.
With a small investment of time, Illustrator scripting can be the assistant you need. You can start with
short, simple scripts that save you a few seconds every day, and move on to scripts that work all night
while you’re sleeping.
Think about your work—is there a repetitive task that’s driving you crazy? If so, you’ve identified a
candidate for a script. What are the steps involved in performing the task? What are the conditions in
which you need to do the task? Once you understand the process you go through to perform the task,
you’ll be ready to turn it into a script.
What about actions?
Illustrator actions are different from scripts. An Illustrator action is a series of tasks you have recorded while
using the application—menu choices, tool choices, object selection, and other commands. When you
“play” an action, Illustrator performs all of the recorded commands.
You record, play, edit, and delete actions using the built-in Actions palette. The “Automating Tasks” chapter
in the Adobe Illustrator User Guide covers actions in detail.
With the introduction of scripting for Illustrator, it is important to avoid any confusion about the difference
between actions and scripting. Actions and scripts are both ways of automating repetitive tasks, but they
work very differently. The following points summarize the key differences.
● Actions use a program’s user interface to do their work. As an action runs, menu choices are executed,
objects are selected, and recorded paths are created. Scripts do not use a program’s user interface to
perform tasks, and can execute faster than actions.
● Actions have very limited facilities for getting and responding to information. You cannot add
conditional logic to an action. Therefore, actions cannot make decisions based on the current situation.
Scripts are capable of getting information and making decisions and calculations based on the
information they receive from Illustrator.
● A script can execute an action, but actions cannot execute scripts.
Adobe Illustrator CS2
JavaScript Scripting Reference Introduction 49
Script Support in Adobe Illustrator CS2
The Scripts menu supports AppleScript and JavaScript scripts for Mac OS, and VBScript, JavaScript, and
Visual Basic for Windows.
For a file to be recognized by Adobe Illustrator CS2 as a valid script file it must have the correct file name
extension:
Script Type File Type Extension Platform
AppleScript compiled script
JavaScript
ExtendScript
VBScript text
Visual Basic executable
JavaScript support
All of the Adobe Creative Suite 2 applications, including Adobe Illustrator CS2, use ExtendScript, Adobe’s
extended implementation of JavaScript. ExtendScript files are distinguished by the
ExtendScript offers all standard JavaScript features, plus additional features and utilities, such as:
● A debugging environment (the ExtendScript Toolkit)
● A localization utility
● Tools that allow you to combine scripts and direct them to particular applications
● Platform-independent file and folder representation
For details of these and additional features, see Using File and Folder Objects
Features.
OSAS file
text
.scpt
(none)
.js
.jsx
.vbs
.exe
Mac OS
Mac OS & Windows
Windows
Windows
.jsx extension.
and ExtendScript Tools and
Executing scripts
Adobe Illustrator CS2’s interface includes a Scripts menu (File > Scripts ) which provides quick and easy
access to your scripts. Scripts can be listed directly as menu items, that run when you select them, or you
can navigate to and run any script in your file system.
If Illustrator encounters an error during script execution, it displays the error message returned by the
script in an error dialog.
Note: It is not possible to execute scripts that contain the
Attempting to do so causes an error.
Installing scripts
To install a script in the Scripts menu, place it in the Scripts folder (Illustrator CS2 > Presets > Scripts).
The names of the scripts in the Scripts folder, less any file name extension, will be displayed in the Scripts
menu. Any number of scripts may be installed in the Scripts menu.
do script command from the Scripts menu.
Adobe Illustrator CS2
JavaScript Scripting Reference Introduction 50
Scripts added to the Scripts folder while Illustrator is running will not appear in the Scripts menu until the
next time you launch Illustrator.
If you have a large collection of scripts you wish to use, you may use sub-folders in the Scripts folder to
help organize the scripts in the Scripts menu. Each subfolder will be displayed as a separate submenu
containing the scripts in that subfolder.
Executing other scripts
The Other Scripts item at the end of the Scripts menu (File > Scripts > Other Scripts ) allows you to
execute scripts which are not installed in the Scripts folder. Selecting
Other Scripts displays a file browser
dialog which allows you to select a script file for execution. Only files which are of one of the supported file
types are displayed in the browse dialog. When you select a script file, it is executed the same way as an
installed script.
Startup scripts
On startup,Adobe Illustrator CS2 executes all .jsx files that it finds in the startup folders.
● In Windows, the general startup folder for user-defined scripts is:
%APPDATA%\Adobe\StartupScripts
The Illustrator-specific startup folder is:
Illustrator_install_dir\Startup Scripts
● In Mac OS, the general startup folder for user-defined scripts is:
~/Library/Application Support/Adobe/StartupScripts/
The Illustrator-specific startup folder is:
Illustrator_install_dir/Startup Scripts/
If your script is in the general startup folder, it is also executed by all other Adobe Creative Suite 2
applications at startup. If such a script is meant to be executed only by Illustrator, it must include the
ExtendScript
#target directive ( #target illustrator) or code such as the following:
if( BridgeTalk.appName == "illustrator" ) {
//continue executing script
}
For additional details, see Script Locations and Checking Application Installation .
Changes Since Earlier Versions
The following changes have been made to the JavaScript object model and language support in Adobe
Illustrator CS2:
● Updates to PDFSaveOptions, SVGExportOptions, and FlashExportOptions to reflect new
capabilities in the corresponding dialogs.
● In earlier version, a script used RasterItems.add() to place a raster file format into a document. In
this version, use
PlacedItem.embed function, which converts it to an embedded RasterItem or art items.
PlacedItems.add() instead. To embed the art in the document, use the
Adobe Illustrator CS2
JavaScript Scripting Reference Introduction 51
● New scripting capability for converting raster art into vector art, called tracing . The tracing operation
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.
● New methods PlacedItems.trace and RasterItems.trace initiate tracing, creating a new
PluginItem for the new vector art.
● PluginItem.isTracing is true for the new item, and PluginItem.tracing contains a
reference to a new
● The TracingObject.tracingOption property references a TracingOptions object that
TracingObject object.
collects the parameters used for the tracing operation. You can save tracing options to a preset file,
and load previously saved tracing presets, using the
TracingOptions.loadFromPreset and
TracingOptions.storeToPreset methods.
● New scripting support for underline and strikethrough font styles.
● Support for interapplication communication among Adobe Creative Suite 2 applications through
exported ExtendScript functions and interapplication messaging. For details, see the Creative Suite 2
Bridge JavaScript Reference.
● Support for the ExtendScript Toolkit and other ExtendScript features and utilities. See ExtendScript
Tools and Features.
2
Scripting Basics
When you use Illustrator, you work with documents and their contents. You create documents, layers,
colors, and design elements. You probably think of these things as objects, that you can look at and move
around, and they are in fact represented by objects in the Illustrator object model. The Illustrator object
model contains documents, layers, colors, and page items—objects that can appear in an Illustrator
document.
Automating Illustrator with scripting uses the same object-oriented way of thinking. Each type of object
has its own special properties, and the scripting language has ways to look at and change these
properties.
This chapter provides a brief introduction to the basic concepts and syntax of the JavaScript scripting
language. A bibliography at the end contains references to more complete language guides.
● For more information on the Illustrator object model and specific Illustrator concepts, see ‘Scripting
Illustrator’ on page 60.
● For detailed information on the JavaScript Illustrator objects and methods, see ‘JavaScript Object
Reference’ on page 74.
Object model concepts
In object-oriented programming, objects belong to classes and have properties that describe them. You
manipulate the objects and their properties using functions in JavaScript. (These are also called methods,
and in some scripting languages, commands.) What do these terms mean in this context?
Here’s a way to think about objects and their properties. Imagine that you live in a house that responds to
your commands (you can think of this house as technologically advanced, or magical, or both). The house
is an object, and its properties might include the number of rooms, the color of the exterior paint, or the
date of its construction.
Your house can also contain other objects. Similarly, the objects within the house can also contain smaller
objects. Each room, for example, is an object in the house, while each window, door, or appliance is an
object inside a room.
Each object can respond to various commands according to its capabilities. Windows and doors, for
example, can open or close—but the floor and ceiling cannot. Using scripting, you can talk to each object
directly, or you can talk to them as part of the container. You have to be very specific, though—you can’t
tell your house to open a window without telling it which window you want to open. So windows, like all
other objects, need names or at least a numbering system so you can refer to them specifically. For
example, you might say “Tell the house to open the north window of the living room.”
Objects also have properties that describe specific details about them, like color and size. Imagine that the
properties of objects in your house can be changed. You might say, “Door, paint yourself blue.” Because
your door can respond to the command “paint,” you’ll soon have a door of a different color.
Now let’s apply this object model idea to Illustrator. The Illustrator application is the house, its documents
are the rooms, and the objects in your documents are the windows and doors. You can tell Illustrator
documents to add and remove objects. You can ask objects to get or change their properties.
52
Adobe Illustrator CS2
JavaScript Scripting Reference Scripting Basics 53
Object classes and containers
Objects with the same properties and behaviors are grouped into “classes.” In the house example,
windows and doors belong to their own classes, since they have unique properties, like number of panes
for windows or the door style for doors. In Illustrator, every type of graphic object—paths, text, meshes,
and so on—belongs to its own class, each with its own set of properties and behaviors. Properties such as
VisibleBounds, Width, and Height, for example, are common to all PageItems.
Some types of objects are containers: the house contains rooms. Similarly, a document object might
contain text or image objects. There are hierarchies of containment; the house contains a room, which
contains a door. In a document that contains text, the text object might further contain sentences, that
contain words, that contain characters.
Object inheritance
Objects can share an overall set of properties, but specialize them in different ways. In our house example,
houses have various types of openings, including doors and windows. They all share the property of being
open or closed, for example, and of having hinges.
You can define a parent class for the most general set of shared properties in such a hierarchy. This is called
a superclass . Each specialization can then be a child of that parent, or subclass . The child classes may
inherit , or share, the properties of the parent. Windows and doors can be subclasses of an openings class,
which contains properties that are common to all types of openings, such as open-state. In Illustrator,
PathItems, for example, inherit geometric properties like Width and Height from the PageItem class.
Subclasses often have additional properties that are not shared with their superclass. In our house, both a
window and door inherit an open-state property from the opening class, but a window has
number-of-panes property which the opening class does not. In Illustrator,
the property
StrokeColor which is not inherited from the PageItem class.
Object elements or collections
Object collections , in JavaScript, are objects contained within other objects. For example, rooms are
elements (or collections) of our house, contained within the house object. In Illustrator, documents are
elements of the application object, and page items are elements of a document object.
Object references
The objects in your documents are arranged in a hierarchy like the house object—page items are in layers,
which are inside a document, which is inside Illustrator. When you send a message to an Illustrator object,
you need to make sure you send it to the right object. To do this, you identify objects by their position in
the hierarchy. You might, for example, write the following statement.
Documents(1).Layers(1).PageItems(1)
When you identify an object in this fashion, you’re creating an object reference , to give the script a way of
finding the object you want to work with.
PathItems, for example, have
Adobe Illustrator CS2
JavaScript Scripting Reference Scripting Basics 54
Scripting concepts
This section discusses various basic programming and scripting features and how they are used in the
JavaScript language. Adobe Illustrator CS2 uses ExtendScript, which is Adobe’s extended implementation
of JavaScript. The terms ExtendScript and JavaScript are generally used interchangeably.
Comments
Comments are a way to add descriptive text to a script. Comments come in handy when you want to
document the operation of a script (for yourself or for someone else). The use of comments is the most
important technique for good scripting. Comments are where you should leave important notes about
the specific operation of a script that might provide valuable help when the script is modified at a later
date. The time you save later trying to figure out what the script does may be your own. Comments are
ignored by the scripting system as the script executes and cause no run-time speed penalty.
In JavaScript, use // (double slash) to the left of a single-line comment.
// This is a comment
For a multiple-line comment, use /* at the beginning, and */ at the end:
/* This is a comment
that continues onto
more than one line */
Long script lines
In JavaScript, you use a semicolon (;) to separate one statement from another, but this is optional if there
is only one statement on a line.
In some cases, individual script lines (single statements) are too long to print on a single line in this guide.
JavaScript does not need a line continuation character (as some scripting languages do), so when this
happens, the next line is simply indented for readability.
Case sensitivity
The JavaScript language is case sensitive. The name myField is considered different from myfield .
Value types
Values are the data your scripts use to do their work. Most of the time, the values used in your scripts will
be numbers or text. The following table shows the basic JavaScript value types:
Adobe Illustrator CS2
JavaScript Scripting Reference Scripting Basics 55
Value type What it is Example:
Boolean
Number
String
Object
Logical true or false
Used for all numeric values. JavaScript does not
distinguish between integers and floating-point
values. All numbers are represented internally a
64-bit IEEE floating-point values.
Do not write integers with leading zeroes.
JavaScript interprets a leading
octal number. A leading
0 as indicating an
0x indicates a
hexadecimal number.
A series of text characters. Strings appear inside
single or double quotation marks. You can use
either type, as long as they match. One string can
enclose another by using the opposite type.
A structure that holds a collection of
name:value
pairs. The names are called the properties of the
object. The value of property can be a value of any
type, including another object.
For object types defined in Illustrator, use the
new
function to create new objects. Use the
assignment operator (
=) to retrieve and change
object properties.
true, false
14, 13.9972, -5, 6.023e+23
"I am a string"
’another string’
"One string contains ’another
string’ in single quotes"
{name :"Jane", age: 37, sex:
"F"}
Arrays and functions are special types of objects.
Variables
Variables are containers for data. A variable might contain a number, a string, a list (or array), or an object
reference. Variables have names, and you refer to a variable by its name. To put data into a variable, we
assign the data to the variable. The file name of the current Illustrator document or the current date are
both examples of data that can be assigned to a variable.
Why not simply enter the value directly in the script rather than using a variable? When you use a value
directly the flexibility of script is reduced. By using variables the scripts you write will be reusable in a wider
variety of situations. As a script executes, it can assign data to the variables that reflect the state of the
current document and selection, for example, and then make decisions based on the content of the
variables.
Declaring variables and assigning values
In JavaScript, declare a variable with the keyword var :
var myString;
To assign a value, use the assignment operator, the equal sign. Typically you declare the variable and
assign the initial value in the same statement:
var myString = "Hello, World!"
Adobe Illustrator CS2
JavaScript Scripting Reference Scripting Basics 56
Variables can store references to objects. In this case, the variable name is the name of the object, and you
access the object’s properties through that name:
var person1 = {name :"Jane", age: 37, sex: "F"};
var age1 = person1.age;
Variable naming
Try to use descriptive names for your variables—something like firstPage or corporateLogo, rather
than
x or c. While it will take a little more time to type the longer names, using them will make your scripts
much easier to read. The length of a variable’s name has no effect on the execution speed of your script, so
use descriptive names.
You can also give your variable names a standard prefix so that they’ll stand out from the objects,
commands, and keywords of your scripting system.
Variable names must be a single word, but you can use internal capitalization (such as
underscore characters (
with a number, and they cannot contain punctuation or quotation marks.
Operators
Operators perform calculations (addition, subtraction, multiplication, and division) on variables or values
and return a result. For example:
docWidth/2
This returns a value equal to half of the content of the variable docWidth . So if docWidth contained the
number
You can also use operators to perform comparisons (equal to, not equal to, greater than, or less than). For
example:
docWidth > docHeight
This returns the value true if docWidth is greater than docHeight , or false , if it is not.
Some operators differ between languages For example, JavaScript uses
The equality operator,
The assignment operator,
You can combine this with other arithmetic or logic operators. For example the following statement do
the same thing:
myFirstPage) or
my_first_page) to create more readable names. Variable names cannot begin
20.5, the value returned would be 10.25.
!= as the non-equality symbol.
==, compares two values and returns true if they are equal.
=, sets the value of the leftmost component to be the rightmost component.
a += 5;
a = a + 5;
Use the ampersand (& ) as the concatenation operator to join two strings.
"Pride " & "and Prejudice."
This returns the string “Pride and Prejudice.”
Adobe Illustrator CS2
JavaScript Scripting Reference Scripting Basics 57
Functions
If objects are “nouns” and properties are “adjectives” in our scripting systems, then functions are the
“verbs”—they’re the parts of the script that make things happen. The type of the object you’re working
with determines which methods you can use to manipulate it.
To reuse a particular piece of code, make it a function, then call it by name. Some languages call such
functions routines , subroutines , or handlers . In JavaScript, use the
function (as shown in the example of a conditional statement below).
function keyword to define a new
Conditional statements
If you could speak to Illustrator in the course of a work session, you might say, “If the selected object is a
path, then set its stroke width to 12 points.” Conditional statements make decisions—they give your
scripts a way to evaluate something (the color of the selected object, or the number of color swatches in
the document, or the date) and then act according to the result. Conditional statements generally start
with the word
The following example checks the number of currently open documents. If no documents are open, the
function displays a message to that effect in a dialog box, and if any are open, the function shows the
number.
if.
function showDocCount(){
var appRef = New Illustrator.Application;
var documentCount = appRef.Documents.Count;
if documentCount = 0
Window.alert("No Illustrator documents are open");
else Window.alert("There are "+documentCount+" documents open.")
}
Control structures
If you could talk to Illustrator, you might say, “Repeat the following procedure twenty times.” In scripting
terms, this sort of direction is called a “control structure.” Control structures provide for repetitive
processes, or “loops.” The idea of a loop is to repeat some action over and over again, with or without
changes each time through the loop, until some condition is met.
JavaScript has a variety of different control structures to choose from. The simplest form of a loop is one
that repeats some series of script operations a set number of times.
for counter = 1 to 20 {
MsgBox counter
}
A more complicated type of control structure includes conditional logic, so that it loops while or until
some condition is true or false.
while flag = false {
flag = (MsgBox ("Quit?", vbOKCancel)) = vbCancel
}
do {myFunction ();} while flag = false;
Adobe Illustrator CS2
JavaScript Scripting Reference Scripting Basics 58
Including Other Script Files
ExtendScript for Illustrator provides two file-inclusion directives. One allows you to include another
JavaScript script file in this script, and the other specifies a search path for included script files.
Directive Description
@include
script
Provides the name of a script to include in the current script, given as an absolute
or relative path and file name. The file must exist; if it is not found, a run-time error
occurs.
The script is read directly into the current script at the point where this statement
is encountered, and is treated in every way as if the script was directly pasted into
this file. The inclusion process is done before the current script is evaluated.
@includepath
path
Provides a search path on which to look for JavaScript files named in subsequent
@include statements. The comment containing this directive must be placed
above any
@include statement to which it should apply.
The include functionality makes it much easier for Adobe scripters to build, pre-test, and use libraries of
pre-made JavaScript functions to enable code reuse and to facilitate sharing with other users.
For example:
@includepath “~/MainScripts;../OtherScripts”
@include “scriptname.js”
In this case, Illustrator searches for the file scriptname.js in the following folders, in this order:
● The current working folder (always)
● The MainScripts folder in the current user’s home folder
● The OtherScripts folder one level up from the current working folder
For additional details, see Chapter 7, "ExtendScript Tools and Features
Testing and troubleshooting
The scripting environment provides tools for monitoring the progress of your script while it is running—
which makes it easier for you to track down any problems your script might be encountering or causing.
For JavaScript, the ExtendScript Toolkit provides a view into your scripts. This tool allows you to execute
specific statements, step through execution of a script, and set and check the values of script variables
interactively.
● The Scripts pane allows you to load and display any script that Illustrator can access in the file system.
● Scripts are displayed in the main Editor pane. You can edit a displayed script, save it, or run it. You can
set breakpoints in the script, to stop execution at that point, then step through it statement by
statement.
● The JavaScript Console is an output window for your scripts; you can include writeln statements to
print messages into this window to help debug your scripts.
● The command line above the Console allows you to enter and execute individual JavaScript
statements without saving them in scripts. For example, you can check or set variable values in the
current script.
."
Adobe Illustrator CS2
JavaScript Scripting Reference Scripting Basics 59
● The Call Stack pane shows the sequence of function calls during execution. If execution stops because
of a breakpoint you have set or because of a run-time error, you can see exactly what sequence of calls
has occurred.
For detailed information about using the ExtendScript Toolkit, see Chapter 7, "ExtendScript Tools and
Features."
About error handling
Imagine that you’ve written a script that formats the current text selection. What should the script do if the
current selection turns out not to be text at all, but a path item? You can add error handling code to your
script to respond to conditions other than those you expect it to encounter.
If you have complete control over the situations in which your script will run, there’s no need for you to
worry about error handling. If not, however, you’ll have to add some error handling capabilities to your
script.
When an error occurs, you can handle it in different ways, depending on what happened. JavaScript allows
you to use the
catch, and finally statement blocks for to handle that information. You can throw specific values of
any type, or the
throw statement to send information to another part of your program, which can use try,
Error objects that JavaScript generates for run-time errors.
JavaScript Resources
For documentation of the JavaScript language and descriptions of how to use it, see any of numerous
works on this subject, including the following:
JavaScript: The Definitive Guide, 4th Edition; Flanagan, D.; O’Reilly 2001; ISBN 0-596-00048-0
JavaScript Programmer’s Reference; Wootton, C.; Wrox 2001; ISBN 1-861004-59-1
JavaScript Bible. 5th Edition; Goodman, D. and Morrison, M.; John Wiley and Sons1998; ISBN
0-7645-57432
3
Scripting Illustrator
This chapter describes the Illustrator object model, and provides an overview of how to use JavaScript to
program Illustrator CS.
The Illustrator object model
A good understanding of the Illustrator object model will improve your scripting abilities. The figure below
shows the containment hierarchy of the object model, starting with the Application object. The
and
GroupItem classes and all text classes can contain additional objects of the same class which can, in
turn, contain additional nested objects.
Layer
Tex t Fo nt
Paragraph Style
Character Style
Gradient
Dataset
Variable
Swatch
Application
Document
Layer
Group Item
Graphic Style
Spot
View
Symbol
Pattern
Story
Ink List
Page Item
Compound
Path Item
Graph Item
Mesh Item Brush
Path Item
Placed Item
Plugin Item
Raster Item
Symbol Item
Text Frame
Legacy Text Item
Path Item
Path Point
Printers
PPD File List
Print Preset List
PDF Preset List
Flattener Preset List
Illustrator Scripting Object Model
WIthin text, characters, words, paragraphs, and lines are all represented by the TextRange object. For
example, a character is a
before it. These types of text ranges are collected into collection objects;
TextRange with a length of 1, and a word is a TextRange that has a space
Characters, Words,
Paragraphs, and Lines. For additional text-related objects, see Working with Text and Printing .
In addition to the application-specific object model, ExtendScript provides the
which give you operating-system-independent access to the file system. For details, see Chapter 4, “
File and Folder objects,
Using
File and Folder Objects.”
60
Adobe Illustrator CS2
JavaScript Scripting Reference Scripting Illustrator 61
Referencing and Creating Objects in JavaScript
As the object model diagram shows, all objects are arranged in a hierarchy. To obtain a reference to a
specific object you need to navigate the hierarchy. For example, to store a reference to the first path item
in the second layer of the active document in the variable
pathRef = app.activeDocument.layers[1].pathItems[0];
All array references in JavaScript are zero-based. The first element of an array is index [0]. You can refer to
objects in a collection by index number ( [ i ] ) or by name. For example, you can refer to the “Black” swatch
in either of these ways:
app.activeDocument.swatches[4]
app.activeDocument.swatches["Black"]
For some types of objects, the name property is writable. The collections are sorted alphabetically by
name, so if a script modifies the name of such an object, references to that object by the old name or index
can become invalid. These object types include the following:
Brush
Gradient
GraphicStyle
Pattern
Swatch
Symbol
Variable
pathRef, you would write:
The following collection objects do not have names; you can only reference them by index.
Characters
GradientStops
Lines
Paragraphs
PathPoints
Words
Since all JavaScript scripts are executed from within the Illustrator application, a specific reference to the
application object is not required. For example, to assign the active document in Illustrator to the variable
frontMostDocument, you would reference the activeDocument property of the application object as
follows:
frontMostDocument = app.activeDocument;
There are a number of objects that cannot be obtained by using the hierarchy shown in the object model
diagram. You must create these explicitly by defining a variable, using the new object constructor, and
assigning objects or values to them. For example, to create the new
CMYKColor object, newCMYKColor:
var newCMYKcolor = new CMYKColor();
The following objects must be created:
CMYKColor
Color
EPSSaveOptions
ExportOptionsFlash
ExportOptionsGIF
ExportOptionsJPEG
ExportOptionsPhotoshop
ExportOptionsPNG8
ExportOptionsPNG24
ExportOptionsPS5
ExportOptionsSVG
File
Folder
GradientColor
GrayColor
IllustratorSaveOptions
Matrix
PatternColor
PDFOpenOptions
PDFOpenOptions
PDFSaveOptions
RGBColor
SpotColor
NoColor
Adobe Illustrator CS2
JavaScript Scripting Reference Scripting Illustrator 62
The following example creates a new EPSSaveOptions object, assigns values to it, and saves it to a file
named
\temp\sample.eps in the user’s home folder:
// Create an EPS-save option object
var fileSpec = new File("~/temp/sample.eps");
var newSaveOptions = new EPSSaveOptions();
// Set the options to define how the EPS document is saved by Illustrator
newSaveOptions.embedAllFonts = true;
newSaveOptions.compatibility = Compatibility.ILLUSTRATOR8;
newSaveOptions.preview = EPSPreview.COLORTIFF;
// Save the active document
app.activeDocument.saveAs(fileSpec, newSaveOptions);
Working with the Selection Object
The document selection object returns either an array of art items or a string of text. To correctly
handle the selection, you must first test to see if you have artwork or text. The properties of the art items in
the array of artwork items can only be accessed by referencing the individual items in the array.
The following example checks the type of data contained in the selection object, assigns a name to the
object, and then displays the
typename and toString() values for art items or returns a message that
you have selected text.
// Determine if the selection is an array of art item objects or text.
// Then display the typename and toString() values for each selected item.
mySelection = app.activeDocument.selection;
if (mySelection instanceof Array) {
msgType = "Selection items: ";
msgString = "Selection items: ";
for (i=0; i<mySelection.length; i++) {
mySelection[i].name = "SelectItem " + i;
msgType = msgType + "\nItem[" + i + "] typename is: " +
mySelection[i].typename;
msgString = msgString + "\nItem[" + i + "] toString is: " +
mySelection[i].toString();
}
}
else {
msgType = "You have selected text.";
msgString = "You have selected text.";
}
alert(msgType);
alert(msgString);
Working with paths
Path items include all artwork that contain paths, including rectangles, ellipses, polygons, as well as
freeform paths. In Illustrator, every path consists of a series of points; see the following figure.
Adobe Illustrator CS2
JavaScript Scripting Reference Scripting Illustrator 63
pathPoint
rightDirection
pathItem
anchor
leftDirection
Path items, as well as path points, can be created and manipulated from a script. Every aspect of a path
point can be accessed from scripting, including the
leftDirection and rightDirection properties.
anchor and both control points, known as the
For more information on working with paths, Bézier curves, and path points, refer to the Illustrator Plug-in
Software Development Kit Function Reference. This document is available as part of the Illustrator Software
Development Kit (SDK), which can be downloaded from the Adobe Solutions Network (ASN) web site:
http://partners.adobe.com/asn/developer/sdks.html
Working with color
Swatches can be created and manipulated from your scripts. You can also create new patterns, gradients,
and spot colors from scripts. Just as in the user interface, percentages (0.0 through 100.0) are used to
specify grayscale, individual CMYK values and spot tints. The range 0.0 to 255.0 is used for the individual
RGB color values. Special attention should be paid to working with CMYK and RGB color values. Illustrator
CS supports only a single color model within each document, either CMYK or RGB. When you specify a
CMYK color value in a document that uses the RGB color model, Illustrator will convert the values to RGB
and return an RGB color, and vice-versa when specifying RGB colors in a CMYK document. However, there
is some data loss during this conversion. Refer to the “Applying Color” chapter in the Adobe Illustrator User
Guide for more information on working with color.
Working with symbols and symbol items
Symbols are art items that are stored in the Symbols palette and applied to documents. You can create,
delete, and duplicate symbols. When you create symbols, Illustrator adds them to the Symbols Palette for
the target document. When you save the document, Illustrator also saves the symbols you created and
used in the document.
Symbol items refer to instances of symbols in a document. You can create, delete, and duplicate symbol
items. They are “linked” to the symbol definition such that changing the definition of a symbol causes all of
the instances of the symbol to change as well. Symbol items are Illustrator art items and therefore can be
treated as other art items or page items. In other words, you can rotate, resize, select, lock, hide, and
perform other operations on them.
Working with Methods
When you work with methods that have multiple parameters, you may omit optional parameters at the
end of the parameter list, but you may not omit parameters in the middle of the list. If you do not wish to
specify a particular parameter in the middle of the list, you must insert the string “undefined”. The
Adobe Illustrator CS2
JavaScript Scripting Reference Scripting Illustrator 64
JavaScript interpreter will insert the default parameters wherever “undefined” is specified. For example, to
rotate an object 30 degrees and have the
myObject.rotate(30, undefined, undefined, true)
Note that you only need to specify “undefined” for the changePositions and changeFillPatterns
parameters. You do not have to specify anything for the parameters that follow the
changeFillGradients parameter.
fillGradients changed:
Working with Text and Printing
The following figure shows object model for text.
Application
Document
Character Style
Paragraph Style
The text in an Illustrator document is contained inside a story . A document can have multiple stories, and
each story has a text range . A story can contain one or more text frames . In this case, multiple text frames
are linked together to form a single story. There are special sets of text ranges within a text range that have
semantic meanings such as paragraphs, lines, words, and characters.
There are three types of text frame items in Adobe Illustrator: point text, path text, and area text. The
property of a text frame item is used to determine the type of the text frame item. While all three kinds of
text art have some common characteristics, such as an orientation, each kind of text art also has unique
characteristics.
This is an
example of
point text.
Story
Text Frame
This is
an exam-
ple of area
text.
Text Range
Selection
Paragraphs
Lines
Words
Characters
kind
o
f
e
l
t
p
m
a
x
e
n
a
s
i
s
i
h
T
e
x
t
o
n
a
p
a
t
h
All three kinds of text frames have least one text path associated with them. A
as a path art item, but defines the text frame’s position on the artboard and its orientation (horizontal or
vertical). Point text is defined completely by the properties of its text frame and associated text path.
For path and area text, text paths are associated with normal path art items. These path art items can be
accessed and manipulated to modify the appearance of the associated text frame. If the text frame is path
text, it will have a
startTValue property which indicates where on the path object the text begins.
textPath is not the same
Adobe Illustrator CS2
JavaScript Scripting Reference Scripting Illustrator 65
All text art items also have at least one line of text depending on the object’s geometry. A line of text is
all of the characters that fit on a single line in the text frame item. Text art will have multiple text lines if it
contains hard line breaks or its characters flow to a new line because they do not fit in the width of the text
art. Unlike characters, paragraphs, and words, lines can only be created by the Illustrator application.
Refer to the “Using Type” chapter in the Adobe Illustrator User Guide for more information on working
with text art.
Content of a Text Range
You can set the content of a text range by passing in a Unicode string known to that particular scripting
language. If you know the Unicode value of a character, you can enter it using a C language style backslash
escape sequence. If the string starts with a single or double quote, treat the quote as a delimiter. The exact
escape characters it recognizes depends on the scripting language being used.
Character Style, Character Attributes, Local Character Attributes
You can change the display properties of a text range by applying an appropriate character style and/or
providing local overrides of character attributes at the text and/or paragraph levels.
The character styles are hierarchical, namely you can derive a new character style from another base
(parent) character style, although only one level of inheritance is allowed. The root character style is
named ‘Normal’, with all character attributes defined and set to default values.
If you query for the character attributes of a text range, Illustrator will derive a fully defined/flattened set of
character attributes (because at the root level, ‘Normal’ character style is always fully defined).
This principle also applies the paragraph style, paragraph attributes and local paragraph attributes.
Printing Illustrator Documents
Prior to Illustrator CS, scripters could use the print command, but they could not control any of the print
settings. With the new printing model, you can use the full range of Illustrator print capabilities using
JavaScript. In many instances, the print features available via scripting are greater than those available
through the Illustrator CS print user interface.
Using the print scripting feature, scripters can capture and automate parts of their print workflow, which
allows them to focus on other more creative work. Scripting exposes the full capabilities of Illustrator
printing, some of which may not be accessible through the normal print user interface.
Illustrator supports at most one print session at any give time because of limitations in the current printing
architecture.
When printing, you may provide an options parameter to more fully control the printing process.
Illustrator CS supports an extensive list of new printing options, all of which have default values. As a
scripter, you can override any one of these printing options. If you override a printing option with an illegal
value (such as specifying a printer or paper that does not exist), an error is returned.
The following lists the categories of printing options that you can specify. Each one of these categories is
optional. Within each category, default values have been provided for all properties.
Adobe Illustrator CS2
JavaScript Scripting Reference Scripting Illustrator 66
Print Option Description
Printer name Name of the selected printer
PPD file name File name of the selected PPD file
Print style name Specifies the printing style
Paper options Specifies the paper name and custom paper sizes
Print job options Options which control things such as number of print copies
Color separation options Specifies the separation mode, ink list, etc.
Page marks options Controls the printing of page marks
Coordinate options Specifies the positioning and scaling of artwork on the media
Font options Controls the fonts used for printing
PostScript® options Controls parameters such as the PostScript Language Level
Color management Sets color profiles
Flattener options Controls the transparency flattening
The print settings are determined through the following precedence order:
● The print style settings, if any are specified, will override the default print settings.
● The specific printing options (if there are any) will override the print style settings.
To get lists of printers, PPD files, and so on, you must have a document open or an error is returned.
Measurement units
Illustrator uses points as the unit of measurement for almost all distances, where one inch is equal to 72
points. The one exception is that for values for properties such as kerning, tracking, and the aki properties
(used for Japanese text composition), em units are used (see Em Space Units
Even if you change the current document ruler’s units of measurement, Illustrator still uses points when
communicating with your scripts. If your script depends on adding, subtracting, multiplying, or dividing
specific measurement values for units other than points, it must perform any unit conversions needed to
represent your measurements as points.
For example, to use English measurements such as inch values for coordinates or measurement units, your
script will need to multiply all inch values by 72 to convert to points, since there are 72 points in an inch. To
use metric measurements such as centimeters, you will need to multiply all centimeter values by 28.346,
since there are 28.346 points in a centimeter.
).
This table shows the conversion formulae for various units of measurement:
Unit Conversion formula
centimeters 28.346 points = 1 centimeter
inches 72 points = 1 inch
Adobe Illustrator CS2
JavaScript Scripting Reference Scripting Illustrator 67
Unit Conversion formula
millimeters 2.834645 points = 1 millimeter
picas 12 points = 1 pica
Qs 0.709 point = 1 Q (1 Q equals 0.23 millimeter)
ExtendScript provides the UnitValue object type, which offers unit conversion utilities. For details, see
Specifying Measurement Values
.
Em Space Units
One exception to the rule of points being used for all measurements is the use of em units (a traditional
typesetting measure) for a few properties such as for kerning and tracking. Values for these properties are
measured in thousandths of an em space.
Em units are proportional to the current font size. For example, in a 6-point font, 1 em equals 6 points; in a
10-point font, 1 em equals 10 points. Similarly, a kerning value of 20 em units for a 10-point font would be
equivalent to:
(20 units x 10 points) / 1000 units/em = 0.2 points
Page item positioning and dimensions
Illustrator uses simple two-dimensional geometry to record the position of objects in a document. The
coordinates used in Illustrator are the same as the “traditional” geometric coordinate system you learned
about in school. The horizontal component of a coordinate pair (or “point”) is referred to as “x” and the
vertical position is denoted by “y”. You can see these coordinates in the Info palette when you select or
create an object in Illustrator.
The zero point (0, 0) for coordinate numbering in Illustrator is in the lower left corner of the document. On
the horizontal axis, coordinates to the right of the ruler’s zero point are positive numbers, and on the
vertical axis, coordinates above the zero point are positive. The
lower left corner of the printable region of the document as a fixed point.
Every object, or page item, in a document has a position described by a fixed point and a width and
height. The maximum value allowed for the width or height of a page item is 16348 points.
pageOrigin of a document defines the
Adobe Illustrator CS2
JavaScript Scripting Reference Scripting Illustrator 68
position
controlBounds
visibleBounds
geometricBounds
pageOrigin
(0,0)
Detail
Every page item also has three properties that describe the object’s overall extent using fixed rectangles.
The
geometricBounds of a page item are the rectangular dimensions of the object excluding stroke
width. The
Finally, the
visibleBounds of a page item are the dimensions of the object including any stroke widths.
controlBounds define the rectangular dimensions of the object including in- and out-
control points.
4
Using File and Folder Objects
Overview
Because path name syntax is very different in Windows, Mac OS and UNIX®, Adobe ExendScript defines the
File and Folder objects to provide platform-independent access to the underlying file system. A File
Object represents a disk file, a Folder Object represents a directory or folder.
● The Folder object supports file system functionality such as traversing the hierarchy; creating,
● The File object supports input/output functions to read or write files.
renaming or removing files; or resolving file aliases.
There are several ways to distinguish between a
if (f instanceof File) ...
if (typeof f.open == "undefined") ...// Folders do not open
and Folder objects can be used anywhere that a path name is required, such as in properties and
File
arguments for files and folders. For details about the objects and their properties and methods, see
Chapter 6, “
Note: When you create two
File and Folder Object Reference."
objects. If you open one of them for I/O, the operating system may inhibit access from the other
object, because the disk file already is open.
Specifying Paths
When creating a File or Folder object, you can specify a platform-specific path name, or an absolute or
relative path in a platform-independent format known as universal resource identifier (URI ) notation. The
path stored in the object is always an absolute, full path name that points to a fixed location on the disk.
● Use the toString method to obtain the name of the file or folder as string containing an absolute
path name in URI notation.
● Use the fsName property to obtain the platform-specific file name.
File and a Folder object. For example:
File objects that refer to the same disk file, they are treated as distinct
Absolute and relative path names
An absolute path name in URI notation describes the full path from a root directory down to a specific file
or folder. It starts with one or two slashes (
following describes an absolute location for the file
/dir1/dir2/mydir/myFile.jsx
A relative path name in URI notation is appended to the path of the current directory, as stored in the
globally-available current
the special names dot (
property of the Folder class. It starts with a folder or file name, or with one of
.) for the current directory, or dot dot (..) for the parent of the current directory. A
/), and a slash separates path elements. For example, the
myFile.jsx:
69
Adobe Illustrator CS2
JavaScript Scripting Reference Using File and Folder Objects 70
slash (/ ) separates path elements. For example, the following paths describe various relative locations for
the file
myFile.jsx:
myFile.jsx
./myFile.jsx
../myFile.jsx
../../myFile.jsx
../dir1/myFile.jsx
In the current directory.
In the parent of the current directory.
In the grandparent of the current directory.
In dir1 , which is parallel to the current directory.
Relative path names are independent of different volume names on different machines and operating
systems, and therefore make your code considerably more portable. You can, for example, use an absolute
path for a single operation, to set the current directory in the
paths for all other operations. You would then need only a single code change to update to a new platform
or file location.
Character interpretation in paths
There are some platform differences in how pathnames are interpreted:
● In Windows and Mac OS, path names are not case sensitive. In UNIX, paths are case sensitive.
● In Windows, both the slash ( /) and the backslash (\ ) are valid path element separators.
● In Mac OS, both the slash (/ ) and the colon (:) are valid path element separators.
If a path name starts with two slashes (or backslashes in Windows), the first element refers to a remote
server. For example,
myhost.
//myhost/mydir/myfile refers to the path /mydir/myfile on the server
Folder.current property, and use relative
URI notation allows special characters in pathnames, but they must specified with an escape character (
followed by a hexadecimal character code. Special characters are those which are not alphanumeric and
not one of the characters:
/ - — . ! ~ * ' ( )
A space, for example, is encoded as %20 , so the file name "my file" is specified as "my%20file".
Similarly, the character
This encoding scheme is compatible with the global JavaScript functions
The home directory
A path name can start with a tilde (~ ) to indicate the user's home directory. It corresponds to the platform’s
HOME environment variable.
UNIX and Mac OS assign the
home directory is
Extend Script assigns the home directory value directly from the platform value.
In Windows, the
name or a path name referring to a remote server (such as
variable is undefined, the Extend Script default is the user's home directory, usually the
and Settings\username
/Users/username. In UNIX, it is typically /home/username or /users/username.
HOME environment variable is optional. If it is assigned, its value must be a Windows path
%)
ä is encoded as %E4, so the file name "Bräun" is specified as "Br%E4un".
encodeURI and decodeURI.
HOME environment variable according to the user login. In Mac OS, the default
\\myhost\mydir). If the HOME environment
C:\Documents
folder.
Adobe Illustrator CS2
JavaScript Scripting Reference Using File and Folder Objects 71
Note: A script can access many of the folders that are specified with platform-specific variables through
static, globally-available Folder class properties
; for instance, appData contains the folder that
stores application data for all users.
Volume and drive names
A volume or drive name can be the first part of an absolute path in URI notation. The values are interpreted
according to the platform.
Mac OS volumes
When Mac OS X starts, the startup volume is the root directory of the file system. All other volumes,
including remote volumes, are part of the
rules to interpret the first element of a path name:
● If the name is the name of the startup volume, discard it.
● If the name is a volume name, prepend /Volumes .
● Otherwise, leave the path as is.
Mac OS 9 is not supported as an operating system, but the use of the colon as a path separator is still
supported and corresponds to URI and to Mac OS X paths as shown in the following table. These examples
assume that the startup volume is
MacOSX, and that there is a mounted volume Remote.
/Volumes directory. The File and Folder objects use these
URI path name Mac OS 9 path name Mac OS X path name
/MacOSX/dir/file MacOSX:dir:file /dir/file
/Remote/dir/file Remote:dir:file /Volumes/Remote/dir/file
/root/dir/file Root:dir:file /root/dir/file
~/dir/file /Users/jdoe/dir/file
Windows drives
In Windows, volume names correspond to drive letters. The URI path /c/temp/file normally translates
to the Windows path
If a drive exists with a name matching the first part of the path, that part is always interpreted as that drive.
It is possible for there to be a folder in the root that has the same name as the drive; imagine, for example,
a folder
C:\C in Windows. A path starting with /c always addresses the drive C:, so in this case, to access
the folder by name, you must use both the drive name and the folder name, for example
If the current drive contains a root folder with the same name as another drive letter, that name is
considered to be a folder. That is, if there is a folder
/c/temp/file translates to the Windows path D:\c\temp\file. In this case, to access drive C, you
would have to use the Windows path name conventions.
To access a remote volume, use a uniform naming convention (UNC) path name of the form
//servername /sharename. These path names are portable, because both Max OS X and UNIX ignore
multiple slash characters. Note that in Windows, UNC names do not work for local volumes.
C:\temp\file.
/c/c for C:\C.
D:\C, and if the current drive is D:, the URI path
These examples assume that the current drive is
D:
Adobe Illustrator CS2
JavaScript Scripting Reference Using File and Folder Objects 72
URI path name Windows path name
/c/dir/file c:\dir\file
/remote/dir/file D:\remote\dir\file
/root/dir/file D:\root\dir\file
~/dir/file C:\Documents and Settings\jdoe\dir\file
Aliases
When you access an alias, the operation is transparently forwarded to the real file. The only operations that
affect the alias are calls to
File object represents an alias, the alias property of the object returns true, and the resolve
method returns the
In Windows, all file system aliases (called shortcuts ) are actual files whose names end with the extension
.lnk. Never use this extension directly; the File and Folder objects work without it.
rename and remove, and setting properties readonly and hidden. When a
File or Folder object for the target of the alias.
For example, suppose there is a shortcut to the file
full Windows file name of the shortcut file is
To access the shortcut from a
object’s
open method opens the linked file (in /folder1). Calling the File object’s rename method
renames the shortcut file itself (leaving the
However, Windows permits a file and its shortcut to reside in the same folder. In this case, the
always accesses the original file. You cannot create a
same folder as its linked file.
A script can create a file alias by creating a
its createAlias
method to specify the target of the alias.
Portability issues
If your application will run on multiple platforms, use relative path names, or try to originate path names
from the home directory. If that is not possible, work with Mac OS X and UNIX aliases, and store your files
on a machine that is remote to your Windows machine so that you can use UNC names.
As an example, suppose you use the UNIX machine
in the root directory of
same data location, the path name
/folder1/some.txt in the folder /folder2. The
\folder2\some.txt.lnk.
File object, specify the path /folder2/some.txt. Calling that File
.lnk extension intact).
File object
File object to access the shortcut when it is in the
File object for a file that does not yet exist on disk, and using
myServer for data storage. If you set up an alias share
myServer, and if you set up a Windows-accessible share at share pointing to the
//myServer/share/file would work for all three platforms.
Unicode I/O
When doing file I/O, Adobe applications convert 8-bit character encoding to Unicode. By default, this
conversion process assumes that the system encoding is used (code page 1252 in Windows or Mac Roman
in Mac OS). The
encoding property to the name of the desired encoding. The File object looks for the corresponding
encoder in the operating system to use for subsequent I/O. The name is one of the standard Internet
names that are used to describe the encoding of HTML files, such as
a complete list, see File and Folder Supported Encoding Names
encoding property of a File object returns the current encoding. You can set the
ASCII, X-SJIS, or ISO-8859-1. For
.
Adobe Illustrator CS2
JavaScript Scripting Reference Using File and Folder Objects 73
A special encoder, BINARY, is provided for binary I/O. This encoder simply extends every 8-bit character it
finds to a Unicode character between 0 and 255. When using this encoder to write binary files, the encoder
writes the lower 8 bits of the Unicode character. For example, to write the Unicode character
is 0x3E8, the encoder actually writes the character 232 (0xE8).
The data of some of the common file formats (UCS-2, UCS-4, UTF-8, UTF-16) starts with a special byte order
mark (BOM) character (
character. If it is found, the corresponding encoding is set automatically and the character is skipped. If
there is no BOM character at the beginning of the file,
whether the data might be valid UTF-8 encoded data, and if so, sets the encoding to UTF-8.
To write 16-bit Unicode files in UTF-16 format, use the encoding UCS-2. This encoding uses whatever
byte-order format the host platform supports.
\uFEFF). The File.open method reads a few bytes of a file looking for this
open() reads the first 2 KB of the file and checks
1000, which
When using UTF-8 encoding or 16-bit Unicode, always write the BOM character "
character of the file.
File Error Handling
Each object has an error property. If accessing a property or calling a method causes an error, this
property contains a message describing the type of the error. On success, the property contains the empty
string. You can set the property, but setting it only causes the error message to be cleared. If a file is open,
assigning an arbitrary value to the property also resets its error flag.
For a complete list of supported error messages, see File and Folder Error Messages
\uFEFF" as the first
.
5
JavaScript Object Reference
This section presents all of the object classes in the type library. Each class listing includes the following:
● Properties of the class, including value type, read-only status, and an explanation.
● Methods for the class. Constants and value types needed by the method are shown in bold face.
Required terms are shown in plain face. All items surrounded by brackets [ ] are optional.
● Notes to explain special issues.
● Sample code to help illustrate the syntax and typical workflow usage of the object class.
Note that these examples are intended to be clear demonstrations of syntax, and do not show the best
or most efficient way to construct a JavaScript script. Error checking, for instance, is generally brief or
missing. However, the examples can be combined and expanded to make scripts with greater
functionality.
74
Adobe Illustrator CS2
JavaScript Scripting Reference JavaScript Object Reference 75
Application
The Adobe Illustrator application object, referenced using the pre-defined global app object, which
contains all other Illustrator objects.
Application properties
Property Value type What it is
activeDocument
browserAvailable
documents
flattenerPresetsList
freeMemory
name
path
PDFPresetsList
PPDFileList
preferences
printerList
Document object
boolean
Documents collection
object
object
number (long)
string
File object
object
object
Preference object
Printers collection
object
The active (frontmost) document in Illustrator.
Read-only. If true , a web browser is available.
Read-only. The documents in the application.
Read-only. The list of flattener style names
currently available for use.
Read-only. The amount of unused memory (in
bytes) within the Adobe Illustrator partition.
Read-only. The application’s name (not related to
the filename of the application file).
Read-only. The file path to the application.
Read-only. The list of preset PDF-options names
available for use.
Read-only. The list of PPD files currently available
for use.
The preference settings for Illustrator.
Read-only. The list of installed printers.
printPresetsList
scriptingVersion
selection
textFonts
tracingPresetList
typename
userInteractionLevel
object
string
array of objects
TextFonts collection
object
array of strings
string
UserInteractionLevel
Read-only. The list of preset printing-options
names available for use.
Read-only. The version of the Scripting plugin.
All of the currently selected objects in the active
(frontmost) document.
Read-only. The installed fonts.
Read-only. The list of preset tracing-options
names available for use.
Read-only. The class name of the referenced
object.
What level of interaction with the user should be
allowed when handling script commands.
Adobe Illustrator CS2
JavaScript Scripting Reference JavaScript Object Reference 76
Property Value type What it is
version
visible
Application methods
Method Parameter type Returns What it does
beep
()
concatenateMatrix
(matrix,
secondMatrix)
concatenateRotationMatrix
(matrix,
angle)
concatenateScaleMatrix
(matrix
[,scaleX]
[,scaleY])
concatenateTranslationMatrix
(matrix
[,deltaX]
[,deltaY])
string
boolean
Matrix object
Matrix object
Matrix object
number (double)
object
number (double)
number (double)
Matrix object
number (double)
number (double)
Read-only. The version of the Adobe Illustrator
application.
Read-only. If true , the application is visible.
nothing Alerts the user.
Matrix
object
Matrix
object
Matrix
object
Joins two matrices together.
Joins a rotation translation to a
transformation matrix.
Concatenates a scale
translation to a transformation
matrix.
Matrix
object
Joins a translation to a
transformation matrix.
getIdentityMatrix
()
getRotationMatrix
([angle)
getScaleMatrix
([scaleX]
[, scaleY])
getTranslationMatrix
([deltaX]
[, deltaY])
invertMatrix
(matrix)
isEqualMatrix
(matrix,
secondMatrix)
isSingularMatrix
(Matrix)
number (double)
number (double)
number (double)
number (double)
number (double)
Matrix object
Matrix object
Matrix object
Matrix object
Matrix
object
Matrix
object
Matrix
object
Matrix
object
Matrix
object
boolean
boolean
Returns an identity matrix.
Returns a transformation matrix
containing a single rotation.
Returns a transformation matrix
containing a single scale.
Returns a transformation matrix
containing a single translation.
Inverts a matrix.
Checks whether the two
matrices are equal.
Checks whether a matrix is
singular and cannot be
inverted.
Adobe Illustrator CS2
JavaScript Scripting Reference JavaScript Object Reference 77
Method Parameter type Returns What it does
open
(file
[, documentColorSpace]
[,options])
quit
()
redraw
()
showPresets
(fileSpec)
File object
DocumentColorSpace
anything
File object
Document
object
Opens the file specified by the
string with the specified color
space and options.
If you open a pre-Illustrator 9
document that contains both
RGB and CMYK colors and
documentColorSpace is
supplied, all colors are
converted to the specified
color space. If
the parameter is
not supplied, Illustrator opens
a dialog so the user can
choose the color space.
nothing Quits Illustrator. Note that if the
clipboard contains data,
Illustrator may show a dialog
prompting the user to save the
data for other applications.
nothing Forces Illustrator to redraw all
its windows.
object
Gets presets from the file.
translatePlaceholderText
(text)
string
string
Translates the placeholder text
to regular text (a way to enter
Unicode points in hex values).
➤ Duplicating the active document
In this script, we use the application property activeDocument to duplicate the current document’s
selection before moving it into a new document. This script also demonstrates how to create the new
document.
// Duplicate the selection from the active document into a new document.
// To invoke the JavaScript debugger, remove comment delimiters
//$.level = 1; debugger;
var newItem;
var docSelected = app.activeDocument.selection;
if ( docSelected.length > 0 ) {
// Create a new document and move the selected items to it.
var newDoc = app.documents.add();
if ( docSelected.length > 0 ) {
for ( i = 0; i < docSelected.length; i++ ) {
docSelected[i].selected = false;
newItem = docSelected[i].duplicate( newDoc,
ElementPlacement.PLACEATEND );
}
Adobe Illustrator CS2
JavaScript Scripting Reference JavaScript Object Reference 78
}
else {
docSelected.selected = false;
newItem = docSelected.parent.duplicate( newDoc,
ElementPlacement.PLACEATEND );
}
}
else {
alert( "Please select one or more art objects" );
}
Adobe Illustrator CS2
JavaScript Scripting Reference JavaScript Object Reference 79
Brush
A brush in an Illustrator document. Brushes are contained in documents. Additional brushes may be
created by the user within Illustrator. You can access brushes within a script, but you cannot create them.
Brush properties
Property Value type What it is
name
parent
typename
Brush methods
Method Parameter type Returns What it does
applyTo
(artItem)
➤ Applying a brush
This example duplicates and groups the current selection, applying the third art style in the document to
the items in the group.
// Duplicate and group the current selection,
// and apply a brush to the items as a group
if ( app.documents.length > 0 ) {
docSelection = app.activeDocument.selection;
if ( docSelection.length > 0 ) {
newGroup = app.activeDocument.groupItems.add();
string
Document
object
string
The name of the brush .
Read-only. The document that contains this brush .
Read-only. The class name of the referenced object.
Nothing Applies the brush to a specific art item.
PageItem object
for ( i = 0; i < docSelection.length; i++ ) {
newItem = docSelection[i].duplicate();
newItem.moveToBeginning( newGroup );
}
brush4 = app.activeDocument.brushes[3];
brush4.applyTo( newGroup );
}
}
Adobe Illustrator CS2
JavaScript Scripting Reference JavaScript Object Reference 80
Brushes
A collection of brush objects in a document.
Brushes properties
Property Value type What it is
length
parent
typename
Brushes methods
Method Parameter type Returns What it does
getByName
(name)
index
(itemKey)
➤ Counting brushes
This script displays the total number of available brushes in the current document.
// Count all brushes in active document and display total
if ( app.documents.length > 0 ) {
numberOfBrushes = app.activeDocument.brushes.length;
alert ("There are " + numberOfBrushes
+ " brushes in the active document.");
}
number
object
string
string
string, number
Read-only. The number of objects in the collection.
Read-only. The document that contains this brushes collection.
Read-only. Read-only. The class name of the referenced object.
Brush
object
Brush
object
Gets the first element in the collection with the specified
name.
Gets an element from the collection.
Adobe Illustrator CS2
JavaScript Scripting Reference JavaScript Object Reference 81
CharacterAttributes
Specifies the properties of a character contained in a text frame. A CharacterStyle object associates
these attributes with a specific text range through its
Note: Character attributes do not have default values, and are undefined until explicitly set.
CharacterAttributes properties
Property Value type What it is
characterAttributes property.
akiLeft
akiRight
alignment
alternateGlyphs
autoLeading
baselineDirection
baselinePosition
number (double)
number (double)
StyleRunAlignmentType
AlternateGlyphsForm
boolean
BaselineDirectionType
FontBaselineOption
The amount of inter-character
spacing to be added to the left
side of the character, in
thousandths of an em (that
amount will not compress or
expand during full-justification).
The amount of inter-character
spacing to be added to the right
side of the character, in
thousandths of an em (that
amount will not compress or
expand during full-justification).
The character alignment type.
The alternate glyphs form.
If true , the automatic leading
should be used.
The Japanese text baseline
direction.
The baseline position of text.
baselineShift
capitalization
connectionForms
contextualLigature
discretionaryLigature
figureStyle
fillColor
number (double)
FontCapsOption
boolean
boolean
boolean
FigureStyleType
color object
The amount of shift in points of
the text baseline.
The case of text.
If true , the OpenType®
connection forms should be
used.
If true , the contextual ligature
should be used.
If true , the discretionary ligature
should be used.
Specifies which figure style to use
in an OpenType font.
The color of the text fill.
Adobe Illustrator CS2
JavaScript Scripting Reference JavaScript Object Reference 82
Property Value type What it is
fractions
horizontalScale
italics
kerningMethod
language
leading
ligature
noBreak
openTypePosition
ordinals
boolean
number (double)
boolean
AutoKernType
LanguageType
number (double)
boolean
boolean
FontOpenTypePositionOption
boolean
If true , the OpenType fractions
should be used.
The character horizontal scaling
factor expressed as a percentage
(100 = 100%).
If true , the Japanese OpenType
font supports italics.
The automatic kerning method to
use.
The language of text.
The amount of space between
two lines of text, in points.
If true , the ligature should be
used.
If true , line breaks are allowed.
The OpenType baseline position.
If true , the OpenType ordinals
should be used.
ornaments
overprintFill
overprintStroke
parent
proportionalMetrics
rotation
size
strikeThrough
strokeColor
strokeWeight
boolean
boolean
boolean
object
boolean
number (double)
number (double)
boolean
color object
number (double)
If true , the OpenType ornaments
should be used.
If true , the fill of the text should
be overprinted.
If true , the stroke of the text
should be overprinted.
Read-only. The object’s container.
If true , the Japanese OpenType
font supports proportional
glyphs.
The character rotation angle in
degrees.
Font size in points.
If true , characters use
strike-through style.
The color of the text stroke.
Line width of stroke.
stylisticAlternates
boolean
If true , the OpenType stylistic
alternates should be used.
Adobe Illustrator CS2
JavaScript Scripting Reference JavaScript Object Reference 83
Property Value type What it is
swash
tateChuYokoHorizontal
tateChuYokoVertical
textFont
titling
tracking
Tsume
typename
underline
boolean
number (long)
number (long)
TextFont object
boolean
number (long)
number (double)
string
boolean
If true , the OpenType swash
should be used.
The Tate-Chu-Yoko horizontal
adjustment in points.
The Tate-Chu-Yoko vertical
adjustment in points.
The text font.
If true , the OpenType titling
alternates should be used.
The tracking or range kerning
amount, in thousandths of an em.
An integer.
The percentage of space
reduction around a Japanese
character.
Read-only. The class name of the
object.
If true , characters are underlined.
verticalScale
wariChuCharactersAfterBreak
wariChuCharactersBeforeBreak
wariChuEnabled
wariChuJustification
wariChuLineGap
wariChuLines
wariChuScale
number (double)
number (long)
number (long)
boolean
WariChuJustificationType
number (long)
number (long)
number (double)
Character vertical scaling factor
expressed as a percentage (100 =
100%).
Specifies how the characters in
Wari-Chu text (an inset note in
Japanese text) are divided into
two or more lines.
Specifies how the characters in
Wari-Chu text (an inset note in
Japanese text) are divided into
two or more lines.
If true , Wari-Chu is enabled.
The Wari-Chu justification.
The Wari-Chu line gap.
The number of Wari-Chu
(multiple text lines fit into a space
meant for one) lines.
The Wari-Chu scale.
➤ Setting character attributes
// Character Attributes
// Create a new document add a simple text item
Adobe Illustrator CS2
JavaScript Scripting Reference JavaScript Object Reference 84
var docRef = documents.add();
var textRef = docRef.textFrames.add();
textRef.contents = "I Love Scripting!";
textRef.top = 400;
textRef.left = 100;
// incrementally increase the size of each character
var charCount = textRef.textRange.characters.length;
var size = 100;
for(i=0; i<charCount; i++, size *= 1.2) {
textRef.textRange.characters[i].characterAttributes.horizontalScale
= size;
textRef.textRange.characters[i].characterAttributes.verticalScale
= size;
}
Adobe Illustrator CS2
JavaScript Scripting Reference JavaScript Object Reference 85
Characters
A collection of characters (TextRange objects of length 1). The elements are not named; you must access
them by index.
Characters properties
Property Value type What it is
length
parent
typename
number
object
string
Characters methods
Method Parameter type Returns What it does
add
(contents
[,relativeObject]
[,insertionLocation])
addBefore
(contents)
index
(itemKey)
removeAll
()
Read-only. The number of characters in the collection.
Read-only. The text art item that contains this character.
Read-only. Read-only. The class name of the referenced object.
string
TextRange
TextFrame object
ElementPlacement
Adds a new character with specified text
contents at the specified location in the
current document. If location is not
specified, adds the new character to the
containing text frame after the current
text selection or insertion point.
string
TextRange
TextRange
number
Adds a character before the current text
selection or insertion point.
Gets an element from the collection.
Nothing Deletes all elements in the collection.
➤ Counting characters
This script displays the total number of characters contained in all of the text art items in the current
document.
// Count all characters, including whitespace,
// in the active document and returns the total
if ( app.documents.length > 0 ) {
var doc = app.activeDocument;
var numChars = 0;
for ( i = 0; i < doc.textFrames.length; i++ ) {
textArtRange = doc.textFrames[i].contents;
numChars += textArtRange.length;
}
alert("There are " + numChars
+ " characters, including whitespace, in the document.");
}
Adobe Illustrator CS2
JavaScript Scripting Reference JavaScript Object Reference 86
CharacterStyle
Associates character attributes with characters. For an example, see CharacterStyles.
CharacterStyle properties
Property Value type What it is
characterAttributes
name
parent
typename
CharacterStyle methods
Method Parameter type Returns What it does
applyTo
(textItem
[,clearingOverrides])
remove
()
CharacterAttributes
object
string
object
string
Nothing Applies the character style to the text
object
boolean
Nothing Deletes the object.
Read-only. The character properties for the text
range.
The character style’s name.
Read-only. The object’s container.
Read-only. The class name of the object.
object or objects.
Adobe Illustrator CS2
JavaScript Scripting Reference JavaScript Object Reference 87
CharacterStyles
A collection of CharacterStyle objects.
CharacterStyles properties
Property Value type What it is
length
parent
typename
number
object
string
CharacterStyles methods
Method Parameter type Returns What it does
add
(name)
getByName
(name)
index
(itemKey)
removeAll
()
➤ Using characters styles
/***********************************************************
* Create a character style and apply to each text frame. *
* Character styles allow you to save and apply set of *
* character attributes. *
***********************************************************/
string
string
string, number
Read-only. Number of elements in the collection.
Read-only. The object’s container.
Read-only. The class name of the object.
CharacterStyle
object
CharacterStyle
object
CharacterStyle
object
Creates a named character style.
Gets the first element in the collection with the
provided name.
Gets an element from the collection.
Nothing Deletes all elements in this collection.
// Create a new document add a 3 simple text items
var docRef = documents.add();
var textRef1 = docRef.textFrames.add();
textRef1.contents = "Scripting is fun!";
textRef1.top = 700;
textRef1.left = 50;
var textRef2 = docRef.textFrames.add();
textRef2.contents = "Scripting is easy!";
textRef2.top = 625;
textRef2.left = 100;
var textRef3 = docRef.textFrames.add();
textRef3.contents = "Everyone should script!";
textRef3.top = 550;
textRef3.left = 150;
redraw();
Adobe Illustrator CS2
JavaScript Scripting Reference JavaScript Object Reference 88
// Create a new character style
alert("Create and apply a character style \"BigRed\".");
var charStyle = docRef.characterStyles.add("BigRed");
// set character attributes
var charAttr = charStyle.characterAttributes;
charAttr.size = 40;
charAttr.tracking = -50;
charAttr.capitalization = FontCapsOption.ALLCAPS;
var redColor = new RGBColor();
redColor.red = 255;
redColor.green = 0;
redColor.blue = 0;
charAttr.fillColor = redColor;
// apply to each textFrame in the document
charStyle.applyTo(textRef1.textRange);
charStyle.applyTo(textRef2.textRange);
charStyle.applyTo(textRef3.textRange);
Adobe Illustrator CS2
JavaScript Scripting Reference JavaScript Object Reference 89
CMYKColor
A CMYK color specification, used where a color object is required.
If the color space of a document is
using CMYK, Illustrator will translate 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. Since this
translation can lose information, you should specify colors using the class that matches the document’s
actual color space.
CMYKColor properties
7
Property Value type What it is
black
cyan
magenta
typename
yellow
➤ Setting a CMYK color
This script sets the fill color for the frontmost PathItem in the active document to a light shade of purple.
// Set the fill color of the frontmost path item in
// the current document to a light purple CMYK color
number (double)
number (double)
number (double)
string
number (double)
RGB and you specify the color value for a page item in that document
The black color value. Range 0.0–100.0. Default: 0.0
The cyan color value. Range 0.0–100.0. Default: 0.0
The magenta color value. Range 0.0–100.0. Default: 0.0
Read-only. The class name of the referenced object.
The yellow color value. Range 0.0–100.0. Default: 0.0
if ( app.documents.length > 0 && app.activeDocument.pathItems.length > 0) {
frontPath = app.activeDocument.pathItems[0];
// Set color values for the CMYK object
newCMYKColor = new CMYKColor();
newCMYKColor.black = 0;
newCMYKColor.cyan = 30.4;
newCMYKColor.magenta = 32;
newCMYKColor.yellow = 0;
// Use the color object in the path item
frontPath.filled = true;
frontPath.fillColor = newCMYKColor;
}
Adobe Illustrator CS2
JavaScript Scripting Reference JavaScript Object Reference 90
CompoundPathItem
A compound path. These objects are composed of multiple intersecting paths, resulting in transparent
interior spaces where the component paths overlap. The
paths that make up the compound path.
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 that contains the compound path or
group.
All paths within 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, the properties of all other component paths are updated with
the new value.
CompoundPathItem properties
Property Value type What it is
pathItems property provides access to the
artworkKnockout
blendingMode
controlBounds
editable
geometricBounds
height
hidden
isIsolated
layer
left
locked
name
KnockoutState
BlendModes
array of 4 numbers
boolean
array of 4 numbers
number(double)
boolean
boolean
Layer object
number(double)
boolean
string
Is this object used to create a knockout, and if so, what
kind of knockout.
The mode used when compositing an object.
Read-only. The bounds of the object including stroke
width and controls.
Read-only. If true , this item is editable.
Read-only. The bounds of the object excluding stroke
width.
The height of the compound path item excluding stroke
width.
If true , this compound path item is hidden.
If true , this object is isolated.
Read-only. The layer to which this compound path item
belongs.
The position of the left side of the item.
If true , this compound path item is locked.
The name of this compound path item.
opacity
parent
pathItems
position
number (double)
Layer object or
GroupItem object
PathItems
collection object
array of 2 numbers
The opacity of the object. Range: 0.0 to 100.0
Read-only. The parent of this object.
Read-only. The path art items in this compound path.
The position of the top left corner of the compound
path item excluding stroke width.
Adobe Illustrator CS2
JavaScript Scripting Reference JavaScript Object Reference 91
Property Value type What it is
selected
sliced
tags
top
typename
uRL
visibilityVariable
visibleBounds
width
wrapInside
wrapOffset
boolean
boolean
Tags collection
object
number (double)
string
string
Variable object
array of 4 numbers
number (double)
boolean
number (double)
If true , this compound path item is selected.
If true , the item is sliced. Default: false
Read-only. The tags contained in this object.
The position of the top of the item.
Read-only. Read-only. The class name of the referenced
object.
The value of the Adobe URL tag assigned to this
compound path item.
The visibility variable bound to the item.
Read-only. The visible bounds of the compound path
item including stroke width.
The width of the compound path item excluding stroke
width.
If true , the text frame object should be wrapped inside
this object.
The offset to use when wrapping text around this
object.
wrapped
zOrderPosition
boolean
number (long)
CompoundPathItem methods
Method Parameter type Returns What it does
duplicate
([relativeObject]
[,insertionLocation])
move
(relativeObject,
insertionLocation)
remove
()
If true , wrap text frame objects around this object (text
frame must be above the object).
Read-only. The position of this art item within the
stacking order of the group or layer (
contains the art item.
object
ElementPlacement
object
ElementPlacement
CompoundPathItem
object
Creates a duplicate of the
selected object.
Nothing Moves the object.
Nothing Deletes this object.
Parent) that
Adobe Illustrator CS2
JavaScript Scripting Reference JavaScript Object Reference 92
Method Parameter type Returns What it does
resize
(scaleX,
scaleY
[,changePositions]
[,changeFillPatterns]
[,changeFillGradients]
[,changeStrokePattern]
[,changeLineWidths]
[,scaleAbout])
rotate
(angle
[,changePositions]
[,changeFillPatterns]
[,changeFillGradients]
[,changeStrokePattern]
[,rotateAbout])
transform
(transformationMatrix
[,changePositions]
[,changeFillPatterns]
[,changeFillGradients]
[,changeStrokePattern]
[,changeLineWidths]
[,transformAbout])
translate
([deltaX]
[,deltaY]
[,transformObjects]
[,transformFillPatterns]
[,transformFillGradients]
[,transformStrokePatterns])
number (double)
number (double)
boolean
boolean
boolean
boolean
number (double)
Transformation
number (double)
boolean
boolean
boolean
boolean
Transformation
Matrix object
boolean
boolean
boolean
boolean
number (double)v
Transformation
number (double)
number (double)
boolean
boolean
boolean
boolean
Nothing Scales the art item where scaleX
is the horizontal scaling factor
and
scaleY is the vertical scaling
factor. 100.0 = 100%.
Nothing Rotates the art item relative to
the current rotation. The object
is rotated counter-clockwise if
the
angle value is positive,
clockwise if the value is negative.
Nothing Transforms the art item by
applying a transformation
matrix.
Nothing Repositions the art item relative
to the current position, where
deltaX is the horizontal offset
and
deltaY is the vertical offset.
zOrder
(zOrderCmd)
ZOrderMethod
Nothing Arranges the art item’s position
in the stacking order of the
group or layer (parent) of this
object.
➤ Selecting paths in a document
This example demonstrates how to select all of the paths in a document that are not part of a compound
path or a group by testing the type of the
Parent property with a function.
// Select all paths not part of a compound path.
if ( app.documents.length > 0 ) {
doc = app.activeDocument;
count = 0;
if ( doc.pathItems.length > 0 ) {
thePaths = doc.pathItems;
numPaths = thePaths.length;
for ( i = 0; i < doc.pathItems.length; i++ ) {
pathArt = doc.pathItems[i];
if ( pathArt.parent.typename != "CompoundPathItem" ) {
pathArt.selected = true;
count++;
}
Adobe Illustrator CS2
JavaScript Scripting Reference JavaScript Object Reference 93
}
}
}
alert( "Number of pathItems selected = " + count );
➤
Creating and modifying a compound path item
This example demonstrates how to create a new compound path containing three path items, then
modifies the stroke of the paths in the compound path. Note that when you modify the properties of a
PathItem inside a compound path you affect all paths contained in the compound path. The example
also shows how to access swatches in a document by name.
// Create a CoumpoundPath containing 3 PathItems
// Set the width and the color of the stroke
// (Change affects all paths in the compound path)
if ( app.documents.length > 0 ) {
doc = app.activeDocument;
newCompoundPath = doc.activeLayer.compoundPathItems.add();
// Create the path items
newPath = newCompoundPath.pathItems.add();
newPath.setEntirePath( Array( Array(30, 50), Array(30, 100) ) );
newPath = newCompoundPath.pathItems.add();
newPath.setEntirePath( Array( Array(40, 100), Array(100, 100) ) );
newPath = newCompoundPath.pathItems.add();
newPath.setEntirePath( Array( Array(100, 110), Array(100, 300) ) );
// Set stroke properties of the compound path
newPath.stroked = true;
newPath.strokeWidth = 3.5;
newPath.strokeColor = app.activeDocument.swatches["Orange"].color;
}
Adobe Illustrator CS2
JavaScript Scripting Reference JavaScript Object Reference 94
CompoundPathItems
A collection of CompoundPathItem objects.
CompoundPathItem methods
Property Value type What it is
length
parent
typename
number
object
string
Read-only. The number of objects in the collection.
Read-only. The parent of this collection (either a Layer or a GroupItem ).
Read-only. The class name of the referenced object.
CompoundPathItem methods
Method Parameter type Returns What it does
add
()
getByName
(name)
index
(itemKey)
removeAll
()
➤ Counting compound paths
This example displays the total number of compound paths contained in the first layer of the current
document.
string
string, number
CompountPathItem
object
CompountPathItem
object
CompountPathItem
object
Creates a new CompoundPathItem .
Gets the first element in the collection with
the specified name.
Gets an element from the collection.
Nothing Deletes all elements in this collection.
// Count all compound paths in layer 1 of current document
if ( app.documents.length > 0 ) {
doc = app.activeDocument;
numCompoundPaths = doc.layers[0].compoundPathItems.length;
alert("There are " + numCompoundPaths
+ " compound paths in the active document.");
}
Adobe Illustrator CS2
JavaScript Scripting Reference JavaScript Object Reference 95
Dataset
A set of data used for dynamic publishing. A dataset allows you to collect a number of variables and their
dynamic data into one object. You must have at least one variable bound to an art item in order to create a
dataset. See the class Variable
Dataset properties
Property Value type What is it
.
name
parent
typename
string
Document
object
string
Dataset methods
Method Parameter type Returns What it does
display
()
remove
()
update
()
➤ Using variables and datasets
// Variables and Datasets
//
// Create two variables (visibility and text)
// Create two datasets with different values
// Display both datasets
//
var docRef = documents.add();
Then name of the dataset.
Read-only. The name of the object that contains this dataset.
Read-only. The class name of the referenced object.
Nothing Displays the dataset.
Nothing Deletes this object.
Nothing Updates the dataset.
// Create 2 variables, Visibility and Text
var itemRef = docRef.pathItems.rectangle(600, 200, 150, 150);
var colorRef = new RGBColor;
colorRef.red = 255;
itemRef.fillColor = colorRef;
var visibilityVar = docRef.variables.add();
visibilityVar.kind = VariableKind.VISIBILITY;
itemRef.visibilityVariable = visibilityVar;
// Create a text variable
var textRef = docRef.textFrames.add();
textRef.contents = "Text Variable, dataset 1";
textRef.top = 400;
textRef.left = 200;
var textVar = docRef.variables.add();
Adobe Illustrator CS2
JavaScript Scripting Reference JavaScript Object Reference 96
textVar.kind = VariableKind.TEXTUAL;
textRef.contentVariable = textVar;
redraw();
alert("There are " + docRef.variables.length + " variables.");
alert("Creating 2 new datasets.");
// Create the 1st DataSet
var ds1 = docRef.dataSets.add();
// Change data and create a 2nd dataset
itemRef.hidden = true;
textRef.contents = "Text Variable, dataset 2";
redraw();
var ds2 = docRef.dataSets.add();
alert("Switching to DataSet 1");
ds1.display();
redraw();
alert("Switching to DataSet 2");
ds2.display();
redraw();
Adobe Illustrator CS2
JavaScript Scripting Reference JavaScript Object Reference 97
Datasets
A collection of Dataset objects.
Datasets properties
Property Value type What is it
length
parent
typename
number
Document
object
string
Datasets methods
Method Parameter type Returns What it does
add
()
getByName
(name)
index
(itemKey)
removeAll
()
Read-only. The number of datasets in the collection
Read-only. The name of the object that contains this dataset
Read-only. Read-only. The class name of the referenced object.
string
string, number
Dataset
object
Dataset
object
Dataset
object
Creates a new dataset object.
Gets the first element in the collection with the
specified name.
Gets an element from the collection.
Nothing Removes all elements in the collection.
Adobe Illustrator CS2
JavaScript Scripting Reference JavaScript Object Reference 98
Document
An Illustrator document. 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 specific properties such as
stroked that have default properties.
A document’s color space, height, and width can only be set when the document is created. You cannot
modify these properties in an existing document. See Application
document color spaces are handled.
Document properties
Property Value type What it is
.open for more information on how
fillColor and
activeDataset
activeLayer
activeView
brushes
characterStyles
compoundPathItems
cropBox
cropStyle
dataSets
defaultFillColor
defaultFilled
Dataset object
Layer object
View object
Brushes collection
object
CharacterStyles
collection object
CompoundPathItems
collection object
array of 4 numbers
CropOptions
Datasets collection
object
color object
boolean
The currently opened dataset.
The active layer in the document.
Read-only. The document’s current view.
Read-only. The brushes contained in the
document.
Read-only. The list of character styles in this
document.
Read-only. The compound path items
contained in the document.
The boundary of the document’s cropping box
for output, or
null if no value has been set.
The style of the document’s cropping box.
Read-only. The datasets contained in the
document.
The color to use to fill new paths if
defaultFilled is true.
If true , a new path should be filled.
defaultFillOverprint
defaultStrokeCap
defaultStrokeColor
defaultStroked
boolean
StrokeCap
color object
boolean
If true, the art beneath a filled object should be
overprinted by default.
Default type of line capping for paths created.
The stroke color for new paths if default
stroked is
true.
If true , a new path should be stroked.
Adobe Illustrator CS2
JavaScript Scripting Reference JavaScript Object Reference 99
Property Value type What it is
defaultStrokeDashes
defaultStrokeDashOffset
defaultStrokeJoin
defaultStrokeMiterLimit
defaultStrokeOverprint
defaultStrokeWidth
documentColorSpace
object
number (double)
StrokeJoin
number (double)
boolean
number (double)
DocumentColorSpace
Default 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 object,
{}, for solid line.
The default distance into the dash pattern at
which the pattern should be started for new
paths.
Default type of joints in new paths.
When a default stroke join is set to mitered , this
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. Range: 1 to 500; a value of 1
specifies a bevel join.
If true , the art beneath a stroked object should
be overprinted by default.
Default width of stroke for new paths.
Read-only. The color specification system to
use for this document’s color space.
fullName
geometricBounds
gradients
graphicStyles
graphItems
groupItems
height
inkList
kinsokuSet
File object
array of 4 numbers
Gradients
collection object
GraphicStyles
collection object
GraphItems
collection object
GroupItems
collection object
number (double)
object
object
Read-only. The file associated with the
document, which includes the complete path
to the file.
Read-only. The bounds of the illustration
excluding the stroke width of any objects in
the document.
Read-only. The gradients contained in the
document.
Read-only. The graphic styles defined in this
document.
Read-only. The graph art items in this
document.
Read-only. The group items contained in the
document.
Read-only. The height of the document.
Read-only. The list of inks in this document.
Read-only. The Kinsoku set of characters that
cannot begin or end a line of Japanese text.
Adobe Illustrator CS2
JavaScript Scripting Reference JavaScript Object Reference 100
Property Value type What it is
layers
legacyTextItems
meshItems
mojikumiSet
name
outputResolution
pageItems
pageOrigin
paragraphStyles
Layers collection
object
LegacyTextItems
collection object
MeshItems
collection object
object
string
number (double)
PageItems
collection object
array of 2 numbers
ParagraphStyles
collection object
Read-only. The layers contained in the
document.
Read-only. The text frame items in this story.
Read-only. The mesh art items contained in the
document.
Read-only. A list of names of predefined
Mojikumi sets which specify the spacing for the
layout and composition of Japanese text.
Read-only. The document’s name (not the
complete file path to the document).
Read-only. The current output resolution for
the document in dots per inch (dpi).
Read-only. The page items (all art item classes)
contained in the document.
The zero-point of the page in the document
without margins, relative to the overall height
and width.
Read-only. The list of paragraph styles in this
document.
parent
path
pathItems
patterns
placedItems
pluginItems
printTiles
rasterItems
rulerOrigin
Application object
File object
PathItems
collection object
Patterns collection
object
PlacedItems
collection object
PluginItems
collection object
boolean
RasterItems
collection object
array of 2 numbers
Read-only. The application that contains this
document.
Read-only. The file associated with the
document, which includes the complete path
to the file.
Read-only. The path items contained in this
document.
Read-only. The patterns contained in this
document.
Read-only. The placed items contained in this
document.
Read-only. The plugin items contained in this
document.
Read-only. If true , this document should be
printed as tiled output.
Read-only. The raster items contained in this
document.
The zero-point of the rulers in the document
relative to the bottom left of the document.