You are previewing Adobe® Illustrator® CS2 Official JavaScript Reference.
O'Reilly logo
Adobe® Illustrator® CS2 Official JavaScript Reference

Book Description

Are you a creative professional? Do you spend too much time doing repetitive production tasks such as placing and replacing images, resizing them, dragging them from one document to another, and preparing images for printing instead of being creative? Do you use Adobe Illustrator CS2 and have some experience with scripting? Then this book is for you. Virtually every repetitive or time-consuming task that creative professionals have to do in the Adobe Creative Suite can be streamlined with the help of a script. This book describes how to use JavaScript to manipulate and extend Adobe Illustrator within Adobe Creative Suite 2, and provides reference information for the JavaScript objects, properties, and functions defined by Adobe's applications. Available in print for the first time, this scripting reference provides the information experienced JavaScript user needs to create custom scripts for the Illustrator, whether you're looking to capture and automate parts of the printing process; manipulate swatches to create new patterns, gradients and spot colors; or create a script that applies formatting to selected text or changes a selected path's shape. These are just a few examples of how you can use Illustrator CS2's built-in scripting capabilities to save you from hours of repetitive tasks.

Table of Contents

  1. Copyright
  2. 1. Introduction
    1. Advisory of previous publication
    2. What’s in this book
    3. What is scripting?
      1. Why use scripting?
      2. What about actions?
    4. Script Support in Adobe Illustrator CS2
      1. JavaScript support
      2. Executing scripts
        1. Installing scripts
        2. Executing other scripts
      3. Startup scripts
    5. Changes Since Earlier Versions
  3. 2. Scripting Basics
    1. Object model concepts
      1. Object classes and containers
      2. Object inheritance
      3. Object elements or collections
      4. Object references
    2. Scripting concepts
      1. Comments
      2. Long script lines
      3. Case sensitivity
      4. Value types
      5. Variables
        1. Declaring variables and assigning values
        2. Variable naming
      6. Operators
      7. Functions
      8. Conditional statements
      9. Control structures
      10. Including Other Script Files
    3. Testing and troubleshooting
      1. About error handling
    4. JavaScript Resources
  4. 3. Scripting Illustrator
    1. The Illustrator object model
      1. Referencing and Creating Objects in JavaScript
      2. Working with the Selection Object
      3. Working with paths
      4. Working with color
      5. Working with symbols and symbol items
    2. Working with Methods
    3. Working with Text and Printing
      1. Content of a Text Range
      2. Character Style, Character Attributes, and Local Character Attributes
      3. Printing Illustrator Documents
    4. Measurement units
      1. Em Space Units
      2. Page item positioning and dimensions
  5. 4. Using File and Folder Objects
    1. Overview
    2. Specifying Paths
      1. Absolute and relative path names
      2. Character interpretation in paths
      3. The home directory
      4. Volume and drive names
        1. Mac OS volumes
        2. Windows drives
      5. Aliases
      6. Portability issues
    3. Unicode I/O
    4. File Error Handling
  6. 5. JavaScript Object Reference
    1. Application
      1. Application properties
      2. Application methods
        1. Duplicating the active document
    2. Brush
      1. Brush properties
      2. Brush methods
        1. Applying a brush
    3. Brushes
      1. Brushes properties
      2. Brushes methods
        1. Counting brushes
    4. CharacterAttributes
      1. CharacterAttributes properties
        1. Setting character attributes
    5. Characters
      1. Characters properties
      2. Characters methods
        1. Counting characters
    6. CharacterStyle
      1. CharacterStyle properties
      2. CharacterStyle methods
    7. CharacterStyles
      1. CharacterStyles properties
      2. CharacterStyles methods
        1. Using characters styles
    8. CMYKColor
      1. CMYKColor properties
        1. Setting a CMYK color
    9. CompoundPathItem
      1. CompoundPathItem properties
      2. CompoundPathItem methods
        1. Selecting paths in a document
        2. Creating and modifying a compound path item
    10. CompoundPathItems
      1. CompoundPathItem methods
      2. CompoundPathItem methods
        1. Counting compound paths
    11. Dataset
      1. Dataset properties
      2. Dataset methods
        1. Using variables and datasets
    12. Datasets
      1. Datasets properties
      2. Datasets methods
    13. Document
      1. Document properties
      2. Document methods
        1. Deselect all objects in the current document
        2. Close a document
        3. Create a document with defaults
    14. Documents
      1. Documents properties
      2. Documents methods
        1. Create a new document
    15. EPSSaveOptions
      1. EPSSaveOptions properties
        1. Saving to EPS format
    16. ExportOptionsFlash
      1. ExportOptionsFlash properties
        1. Exporting to Flash format
    17. ExportOptionsGIF
      1. ExportOptionsGIF properties
        1. Export to GIF format
    18. ExportOptionsJPEG
      1. ExportOptionsJPEG properties
        1. Exporting to JPEG format
    19. ExportOptionsPhotoshop
      1. ExportOptionsPhotoshop properties
        1. Export to Photoshop format
    20. ExportOptionsPNG8
      1. ExportOptionsPNG8 properties
        1. Export to PNG8 format
    21. ExportOptionsPNG24
      1. ExportOptionsPNG24 properties
        1. Export to PNG24 format
    22. ExportOptionsSVG
      1. ExportOptionsSVG properties
        1. Export to SVG format
    23. Gradient
      1. Gradient properties
      2. Gradient methods
        1. Creating and applying a gradient
    24. GradientColor
      1. GradientColor properties
        1. Changing a gradient color
    25. Gradients
      1. Gradients properties
      2. Gradients methods
        1. Removing a gradient
    26. GradientStop
      1. GradientStop properties
      2. GradientStop methods
    27. GradientStops
      1. GradientStops properties
      2. GradientStops methods
        1. Adding a new gradient stop
    28. GraphicStyle
      1. GraphicStyle properties
      2. GraphicStyle methods
        1. Applying a graphic style
    29. GraphicStyles
      1. GraphicStyles properties
      2. GraphicStyles methods
        1. Counting graphics styles
    30. GraphItem
      1. GraphItem properties
      2. GraphItem methods
    31. GraphItems
      1. GraphItems properties
      2. GraphItems methods
        1. Rotating graph items
    32. GrayColor
      1. GrayColor properties
        1. Changing a color to gray
    33. GroupItem
      1. GroupItem properties
      2. GroupItem methods
        1. Modifying all objects in a group
    34. GroupItems
      1. GroupItems properties
      2. GroupItems methods
        1. Importing a PDF as a group item
    35. IllustratorSaveOptions
      1. IllustratorSaveOptions properties
        1. Saving with options
    36. Ink
      1. Ink properties
    37. InkInfo
      1. InkInfo properties
        1. Getting ink information
    38. InsertionPoint
    39. InsertionPoints
      1. InsertionPoints properties
      2. InsertionPoints methods
        1. Using insertion points to add spaces
    40. LabColor
      1. LabColor properties
    41. Layer
      1. Layer properties
      2. Layer methods
        1. Bringing a layer to the front
    42. Layers
      1. Layers properties
      2. Layers methods
        1. Finding and deleting layers
    43. LegacyTextItem
      1. LegacyTextItem properties
      2. LegacyTextItem methods
    44. LegacyTextItems
      1. LegacyTextItems properties
      2. LegacyTextItems methods
    45. Lines
      1. Lines properties
      2. Lines methods
    46. Matrix
      1. Matrix properties
        1. Combining matrixes to apply multiple transformations
    47. MeshItem
      1. MeshItem properties
      2. MeshItem methods
        1. Finding and locking mesh items
    48. MeshItems
      1. MeshItems properties
      2. MeshItems methods
        1. Copying mesh items to another document
    49. NoColor
      1. NoColor properties
        1. Using NoColor to remove a fill color
    50. OpenOptions
      1. OpenOptions properties
        1. Automatically updating legacy text on open
    51. PageItems
      1. PageItems properties
      2. PageItems methods
        1. Getting references to external files in page items
    52. Paper
      1. Paper properties
    53. PaperInfo
      1. PaperInfo properties
        1. Finding paper information
    54. ParagraphAttributes
      1. ParagraphAttributes properties
        1. Changing justification in paragraphs
    55. Paragraphs
      1. Paragraphs properties
      2. Paragraphs methods
        1. Counting paragraphs
    56. ParagraphStyle
      1. ParagraphStyle properties
      2. ParagraphStyle methods
    57. ParagraphStyles
      1. ParagraphStyles properties
      2. ParagraphStyles methods
        1. Creating and applying a paragraph style
    58. PathItem
      1. PathItem properties
      2. PathItem methods
        1. Setting colors in a path
        2. Creating a path from straight lines
    59. PathItems
      1. PathItems properties
      2. PathItems methods
        1. Creating a rectangular path item
    60. PathPoint
      1. PathPoint properties
      2. PathPoint methods
    61. PathPoints
      1. PathPoints properties
      2. PathPoints methods
        1. Adding a path point to a path
    62. Pattern
      1. Pattern properties
      2. Pattern methods
    63. Patterns
      1. Patterns properties
      2. Patterns methods
        1. Removing a pattern
    64. PatternColor
      1. PatternColor properties
        1. Modifying and applying pattern colors
    65. PDFFileOptions
      1. PDFFileOptions properties
        1. Opening a PDF with options
    66. PDFSaveOptions
      1. PDFSaveOptions properties
        1. Saving to PDF format
    67. PhotoshopFileOptions
      1. PhotoshopFileOptions properties
        1. Opening a Photoshop file
    68. PlacedItem
      1. PlacedItem properties
      2. PlacedItem methods
        1. Changing the selection state of placed items
    69. PlacedItems
      1. PlacedItems properties
      2. PlacedItems methods
    70. PluginItem
      1. PluginItem properties
      2. PluginItem methods
        1. Copying a plug-in item
    71. PluginItems
      1. PluginItems properties
      2. PluginItems methods
    72. PPDFile
      1. PPDFile properties
    73. PPDFileInfo
      1. PPDFileInfo properties
        1. Setting PPDfile properties
        2. PPDFileInfo and related screen information
    74. Preferences
      1. Preferences properties
    75. PrintColorManagementOptions
      1. PrintColorManagementOptions properties
        1. Managing colors for printing
    76. PrintColorSeparationOptions
      1. PrintColorSeparationOptions properties
        1. Managing color separations for printing
    77. PrintCoordinateOptions
      1. PrintCoordinateOptions properties
        1. Managing print coordinates
    78. Printer
      1. Printer properties
    79. PrinterInfo
      1. PrinterInfo properties
        1. Finding available printers
    80. PrintFlattenerOptions
      1. PrintFlattenerOptions properties
        1. Setting print flattening
    81. PrintFontOptions
      1. PrintFontOptions properties
        1. Printing with font options
    82. PrintJobOptions
      1. PrintJobOptions properties
        1. Printing with job options
    83. PrintOptions
      1. PrintOptions properties
        1. Setting print options
    84. PrintPageMarksOptions
      1. PrintPageMarksOptions properties
        1. Setting page mark printing options
    85. PrintPaperOptions
      1. PrintPaperOptions properties
        1. Setting print paper options
    86. PrintPostScriptOptions
      1. PrintPostScriptOptions properties
        1. Setting PostScript printing options
    87. RasterItem
      1. RasterItem properties
      2. RasterItem methods
    88. RasterItems
      1. RasterItems properties
      2. RasterItems methods
        1. Finding and examining a raster item
    89. RGBColor
      1. RGBColor properties
        1. Setting an RGB color
    90. Screen
      1. Screen properties
    91. ScreenInfo
      1. ScreenInfo properties
        1. Getting screen information
    92. ScreenSpotFunction
      1. ScreenSpotFunction properties
        1. Finding screen spot functions
    93. Spot
      1. Spot properties
      2. Spot methods
        1. Creating a new spot color
    94. SpotColor
      1. SpotColor properties
    95. Spots
      1. Spots properties
      2. Spots methods
        1. Removing spot colors
        2. Creating and applying spot colors
    96. Story
      1. Story properties
        1. Linking text frames into stories
    97. Stories
      1. Stories properties
      2. Stories methods
    98. Swatch
      1. Swatch properties
      2. Swatch methods
        1. Modifying a swatch
    99. Swatches
      1. Swatches properties
      2. Swatches methods
        1. Finding and deleting a swatch
    100. Symbol
      1. Symbol properties
      2. Symbol methods
    101. Symbols
      1. Symbols properties
      2. Symbols methods
        1. Creating a symbol
    102. SymbolItem
      1. SymbolItem properties
      2. SymbolItem methods
    103. SymbolItems
      1. SymbolItems properties
      2. SymbolItems methods
        1. Creating symbol items
    104. TabStopInfo
      1. TabStopInfo properties
        1. Display tab-stop information for a document
    105. Tag
      1. Tag properties
      2. Tag methods
        1. Using tags
    106. Tags
      1. Tags properties
      2. Tags methods
        1. Setting tag values
    107. TextFont
      1. TextFont properties
        1. Setting the font of text
    108. TextFonts
      1. TextFonts properties
      2. TextFonts methods
        1. Finding fonts
    109. TextFrame
      1. TextFrame properties
      2. TextFrame methods
        1. Rotate a text art item
    110. TextFrames
      1. TextFrames properties
      2. TextFrames methods
        1. Creating and modifying text frames
    111. TextPath
      1. TextPath properties
      2. TextPath methods
    112. TextRange
      1. TextRange properties
      2. TextRange methods
        1. Manipulating text
    113. TextRanges
      1. TextRanges properties
      2. TextRanges methods
    114. TracingObject
      1. TracingObject properties
      2. TracingObject methods
    115. TracingOptions
      1. TracingOptions properties
      2. TracingOptions methods
    116. Variable
      1. Variable properties
      2. Variable methods
    117. Variables
      1. Variables properties
      2. Variables methods
    118. View
      1. View properties
        1. Setting a view to full screen
    119. Views
      1. Views properties
      2. Views methods
    120. Words
      1. Words properties
      2. Words methods
        1. Counting words
        2. Applying attributes to words
  7. 6. File and Folder Object Reference
    1. Overview
    2. File Object
      1. File object constructors
      2. File class properties
      3. File class functions
      4. File object properties
      5. File object functions
    3. Folder Object
      1. Folder object constructors
      2. Folder class properties
      3. Folder class functions
      4. Folder object properties
      5. Folder object functions
    4. File and Folder Error Messages
    5. File and Folder Supported Encoding Names
      1. Additional encodings
        1. Common encoding names
        2. Additional Windows encoding names
        3. Additional Mac OS encoding names
        4. UNIX encodings
  8. 7. Scripting Constants
  9. 8. ExtendScript Tools and Features
    1. The ExtendScript Toolkit
      1. Configuring the Toolkit window
      2. Selecting a debugging target
      3. Selecting scripts
      4. Tracking data
      5. The JavaScript console
      6. The call stack
      7. The Script Editor
        1. Mouse navigation and selection
        2. Keyboard navigation and selection
        3. Syntax checking
      8. Debugging in the Toolkit
        1. Evaluation in help tips
        2. Controlling code execution
        3. Visual indication of execution states
        4. Setting breakpoints
          1. Breakpoint icons
          2. The Breakpoints tab
      9. Profiling
    2. Dollar ($) Object
      1. Dollar ($) object properties
      2. Dollar ($) object functions
        1. Object statistics
    3. ExtendScript Reflection Interface
      1. Reflection Object
        1. Reflection object properties
        2. Reflection object functions
          1. Examples
      2. ReflectionInfo Object
        1. ReflectionInfo object properties
    4. Localizing ExtendScript Strings
      1. Variable values in localized strings
      2. Enabling automatic localization
      3. Locale names
        1. How locale names are resolved
      4. Testing localization
      5. Global localize function
    5. User Notification Helper Functions
      1. Global alert function
        1. Examples
      2. Global confirm function
        1. Examples
      3. Global prompt function
        1. Examples
    6. Specifying Measurement Values
      1. UnitValue Object
        1. UnitValue object constructor
        2. UnitValue object properties
        3. UnitValue object functions
      2. Converting pixel and percentage values
      3. Computing with unit values
    7. Modular Programming Support
      1. Preprocessor directives
      2. Importing and exporting between scripts
    8. Operator Overloading
    9. Application and Namespace Specifiers
      1. Application specifiers
      2. Namespace specifiers
    10. Script Locations and Checking Application Installation