A DOBE I ® 10 LLUSTRATOR J S R AVA CRIPT EFERENCE AdobeDeveloperSupport Europe: 345ParkAvenue POBox12356 (cid:1) SanJose, CA95110-2704 EdinburghEH114GJ 408-536-9000 UnitedKingdom FaxYI:206-628-5737 +44.131.458.6800 [email protected] Fax: +44.131.4586801 [email protected] http://partners.adobe.com ii Adobe Illustrator 10 JavaScript Reference Copyright 2001 Adobe Systems Incorporated. All Rights Reserved. The information in this document 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 this document. 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. Adobe, Adobe After Effects, Adobe PhotoDeluxe, Adobe Premiere, Adobe Photoshop, Adobe Illustrator, Adobe InDesign, Adobe Type Manager, ATM and PostScript are trademarks of Adobe Systems Incorporated that may be registered in certain jurisdictions. Macintosh and Apple are registered trademarks, and Mac OS and AppleScript are trademarks of Apple Computer, Inc. Microsoft, Visual Basic, Windows, Windows 95, Windows 98, and Windows NT are registered trademarks of Microsoft Corporation. All other products or name brands are trademarks of their respective holders. Table of Contents Introduction.......................................................................................................1 About this reference...............................................................................................1 About the script examples......................................................................................1 Illustrator’s object model.......................................................................................1 Referencing and Creating Objects in JavaScript...................................................3 Working with Files and Folders.............................................................................5 Working with Methods..........................................................................................5 Working with the Selection Object........................................................................6 Debugging JavaScript.............................................................................................7 Chapter 1: JavaScript Reference.......................................................................9 Application..............................................................................................................9 ArtStyle..................................................................................................................13 ArtStyles................................................................................................................15 Brush.....................................................................................................................16 Brushes..................................................................................................................18 Character...............................................................................................................19 Characters.............................................................................................................22 CMYKColor..........................................................................................................24 Color......................................................................................................................26 CompoundPathItem............................................................................................28 CompoundPathItems...........................................................................................33 Dataset...................................................................................................................34 Datasets.................................................................................................................35 Document.............................................................................................................36 Documents............................................................................................................43 EPSSaveOptions....................................................................................................44 ExportOptionsFlash..............................................................................................46 ExportOptionsGIF................................................................................................48 ExportOptionsJPEG.............................................................................................51 ExportOptionsPhotoshop....................................................................................53 iv JavaScript Reference ExportOptionsPNG24...........................................................................................55 ExportOptionsPNG8.............................................................................................57 ExportOptionsSVG...............................................................................................60 File..........................................................................................................................62 Folder.....................................................................................................................67 Gradient.................................................................................................................70 GradientColor........................................................................................................72 Gradients................................................................................................................74 GradientStop..........................................................................................................75 GradientStops........................................................................................................76 GraphItem..............................................................................................................78 GraphItems............................................................................................................81 GrayColor..............................................................................................................82 GroupItem.............................................................................................................83 GroupItems............................................................................................................87 IllustratorSaveOptions..........................................................................................88 Layer.......................................................................................................................90 Layers......................................................................................................................93 Matrix.....................................................................................................................95 MeshItem...............................................................................................................97 MeshItems............................................................................................................101 PageItems.............................................................................................................103 Paragraph.............................................................................................................105 Paragraphs............................................................................................................109 PathItem...............................................................................................................111 PathItems.............................................................................................................117 PathPoint.............................................................................................................119 PathPoints............................................................................................................120 Pattern..................................................................................................................121 PatternColor........................................................................................................122 Patterns................................................................................................................124 PDFOpenOptions................................................................................................125 PDFSaveOptions..................................................................................................126 PhotoshopFileOptions........................................................................................128 PlacedItem...........................................................................................................129 PlacedItems..........................................................................................................133 PluginItem...........................................................................................................134 PluginItems..........................................................................................................138 Preferences...........................................................................................................139 RasterItem............................................................................................................140 RasterItems..........................................................................................................144 RGBColor.............................................................................................................146 Adobe Illustrator 10 JavaScript Reference Manual v Spot......................................................................................................................148 SpotColor.............................................................................................................150 Spots.....................................................................................................................151 Swatch..................................................................................................................153 Swatches...............................................................................................................154 Symbol.................................................................................................................155 SymbolItem.........................................................................................................156 SymbolItems........................................................................................................159 Symbols................................................................................................................160 Tag........................................................................................................................161 Tags......................................................................................................................163 TextArtItem.........................................................................................................165 TextArtItems........................................................................................................170 TextFace...............................................................................................................171 TextFaces..............................................................................................................172 TextLine...............................................................................................................173 TextLines..............................................................................................................177 TextPath...............................................................................................................179 TextPaths.............................................................................................................181 TextPath_PathItems............................................................................................182 TextRange............................................................................................................183 Variable................................................................................................................187 Variables...............................................................................................................188 View......................................................................................................................189 Views....................................................................................................................190 Word....................................................................................................................191 Words...................................................................................................................195 Chapter 2: Scripting Constants.................................................................... 197 BlendModes....................................................................................................197 CharacterDirection..........................................................................................197 ColorDitherMethod.........................................................................................198 ColorModel.....................................................................................................198 ColorReductionMethod..................................................................................198 ColorType.......................................................................................................198 Compatibility..................................................................................................198 CompressionQuality.......................................................................................199 CropOptions...................................................................................................199 DocumentColorSpace.....................................................................................199 DocumentType...............................................................................................199 EPSPreview....................................................................................................199 ExportType.....................................................................................................200 FlashExportStyle.............................................................................................200 FlashImageFormat..........................................................................................200 vi JavaScript Reference FlashJPEGMethod..........................................................................................200 GradientType..................................................................................................200 ImageColorSpace............................................................................................200 Justification.....................................................................................................200 KnockoutState................................................................................................201 MonochromeCompression..............................................................................201 OutputFlattening.............................................................................................201 PathPointSelection..........................................................................................201 PDFCompatibility...........................................................................................201 PointType........................................................................................................201 PolarityValues................................................................................................201 PostScriptLevel...............................................................................................201 RasterLinkState..............................................................................................202 RulerUnits.......................................................................................................202 SaveOptions....................................................................................................202 ScreenMode....................................................................................................202 StrokeCap.......................................................................................................202 StrokeJoin.......................................................................................................202 SVGCSSPropertyLocation.............................................................................202 SVGFontSubsetting........................................................................................203 TabStopAlignment..........................................................................................203 TextOrientation...............................................................................................203 TextType.........................................................................................................203 Transformation...............................................................................................204 UserInteractionLevel......................................................................................204 VariableKind..................................................................................................204 ZOrderMethod................................................................................................204 Index...............................................................................................................205 Introduction About this reference This reference section describes the objects and commands in Illustrator’s JavaScript type library. All of the classes in the type library are presented alphabetically. The chapter concludes with a list of all of the constants in the Illustrator type library. Each class listing includes the following: • Properties of the class, including value type, read-only status, and an explanation. (cid:127) 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. (cid:127) Notes to explain special issues. (cid:127) Script examples. About the script examples Many of these examples do not show the most efficient way to construct a JavaScript statement, but they are written to be easy to read and understand. Error checking code, for example, is brief in most of the examples—the point is to show you how to address and work with the Illustrator objects. Many of the examples may be combined to make scripts with greater functionality. Illustrator’s object model A good understanding of Illustrator’s object model will improve your scripting abilities. This diagram shows the containment hierarchy of the object model, starting with the Application object. It is useful to note that all text classes as well as the Layer and GroupItem classes can contain additional objects of the same class which can, in turn, contain additional nested objects. 2 Illustrator’sobjectmodel JavaScriptReference application text face document color-related classes page item gradient path item compound path item pattern tag layer graph item spot mesh item tag swatch group item path point path item tag tag placed art style item tag plugin brush item tag raster data set item tag symbol symbol item path item text art variable item text path tag view insertion character line paragraph text word point text classes AdobeIllustrator10JavaScriptReference ReferencingandCreatingObjectsinJavaScript 3 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 you would write: pathRef = activeDocument.layers[1].pathItems[0]; Note: All array references in JavaScript are zero-based. That is, 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 as: activeDocument.swatches[4] or activeDocument.swatches["Black"] The following collection objects do not have names. You can only reference them by index. (cid:127) Characters (cid:127) GradientStops (cid:127) Paragraphs (cid:127) PathPoints (cid:127) TextLines (cid:127) 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 = activeDocument; There are a number of objects that cannot be obtained by using the hierarchy shown in the object model diagram. These objects must created 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, you would write: var newCMYKcolor = new CMYKColor(); 4 ReferencingandCreatingObjectsinJavaScript JavaScriptReference These objects are: (cid:127) CMYKColor (cid:127) Color (cid:127) EPSSaveOptions (cid:127) ExportOptionsFlash (cid:127) ExportOptionsGIF (cid:127) ExportOptionsJPEG (cid:127) ExportOptionsPhotoshop (cid:127) ExportOptionsPNG8 (cid:127) ExportOptionsPNG24 (cid:127) ExportOptionsPS5 (cid:127) ExportOptionsSVG (cid:127) File (cid:127) Folder (cid:127) GradientColor (cid:127) GrayColor (cid:127) IllustratorSaveOptions (cid:127) Matrix (cid:127) PatternColor (cid:127) PDFOpenOptions (cid:127) PDFSaveOptions (cid:127) RGBColor (cid:127) SpotColor The following example demonstrates how to create a new SaveOptionsEPS object, assign values to it, and save it to a file named \temp\sample.eps. // Create an EPS-save option object var fileSpec = new File("//temp/sample.eps"); var type = ExportType.EPS var newSaveOptions = new SaveOptionsEPS(); // Set the options to define how the EPS document is saved by Illustrator newSaveOptions.embedAllFonts = true; newSaveOptions.compatibility = Compatibility.ILLUSTRATOR7; newSaveOptions.preview = EPSPreview.COLORTIFF; // Save the active document activeDocument.saveAs(fileSpec, type, newSaveOptions);
Description: