Adobe Illustrator scripting
Write, debug, and optimize Adobe Illustrator ExtendScript automation by applying the Illustrator DOM, coordinate system, document and page item APIs, export options, and bundled JSX patterns.
When to invoke
- "Write an Illustrator JSX script."
- "Debug this Adobe Illustrator ExtendScript."
- "Automate Illustrator layers, paths, text, colors, symbols, or artboards."
- "Export Illustrator documents to PDF, SVG, PNG, or EPS with a script."
- "Batch process .ai files with JavaScript."
Expert guidance for automating Adobe Illustrator through ExtendScript (JavaScript/JSX). This skill covers the Illustrator scripting object model, all major API objects, code patterns, and best practices for writing production-quality .jsx scripts.
Bundled Assets
references/object-model-quick-reference.md: Use this as a quick lookup for the Illustrator scripting object model, common document and page item types, and related DOM concepts while writing or debugging scripts.
scripts/: Contains example Illustrator automation scripts you can use as starting points or implementation patterns for common tasks such as document manipulation, exports, batch processing, and DOM usage. Review and adapt these examples when you need working JSX patterns or want to compare behavior while debugging.
Invocation details
- Writing new Illustrator automation scripts (
.jsx or .js files)
- Debugging or fixing existing Illustrator ExtendScript code
- Manipulating documents, layers, page items, paths, text, or colors programmatically
- Batch-processing Illustrator files or generating artwork from data
- Exporting documents to various formats (PDF, SVG, PNG, EPS, etc.)
- Working with the Illustrator DOM (Application, Document, Layer, PathItem, TextFrame, etc.)
- Creating data-driven graphics using variables and datasets
- Automating print workflows with scripted print options
Prerequisites
- Adobe Illustrator CC or later installed
- Basic JavaScript knowledge (ExtendScript is ES3-based with Adobe extensions)
- Scripts are executed via File > Scripts > Other Scripts, the Scripts menu, or placed in the Startup Scripts folder
- The ExtendScript Toolkit (ESTK) or any text editor can be used to write
.jsx files
Scripting Environment
Language and File Extensions
| Language |
Extension |
Platform |
| ExtendScript/JavaScript |
.jsx, .js |
Windows, macOS |
| AppleScript |
.scpt |
macOS only |
| VBScript |
.vbs |
Windows only |
This skill focuses on ExtendScript/JavaScript as the cross-platform, most widely used option.
Executing Scripts
- Scripts menu: File > Scripts lists scripts from the application scripts folder
- Other Scripts: File > Scripts > Other Scripts to browse and run any
.jsx file
- Startup Scripts: Place scripts in the Startup Scripts folder to run automatically on launch
- Target directive: Begin scripts with
#target illustrator when running from ESTK or external tools
#targetengine directive: Use #targetengine "session" to persist variables across script executions
- External invocation: Scripts are frequently launched from outside Illustrator — by shell scripts, task runners, CI jobs, ExtendScript Toolkit (
ExtendScript Toolkit.exe -run script.jsx), or BridgeTalk messages from other Adobe apps. See External Invocation & Argument Passing.
Naming Conventions (JavaScript)
- Objects and properties use camelCase:
activeDocument, pathItems, textFrames
- The
app global references the Application object
- Collection indices are zero-based:
documents[0] is the frontmost document
- Use
typename property to identify object types at runtime
Object Model Overview
The Illustrator DOM follows a strict containment hierarchy:
Application (app)
├── activeDocument / documents[]
│ ├── layers[]
│ │ ├── pageItems[] (all artwork)
│ │ ├── pathItems[]
│ │ ├── compoundPathItems[]
│ │ ├── textFrames[]
│ │ ├── placedItems[]
│ │ ├── rasterItems[]
│ │ ├── meshItems[]
│ │ ├── pluginItems[]
│ │ ├── graphItems[]
│ │ ├── symbolItems[]
│ │ ├── nonNativeItems[]
│ │ ├── legacyTextItems[]
│ │ └── groupItems[]
│ ├── artboards[]
│ ├── views[]
│ ├── selection (array of selected items)
│ ├── swatches[], spots[], gradients[], patterns[]
│ ├── graphicStyles[], brushes[], symbols[]
│ ├── textFonts[] (via app.textFonts)
│ ├── stories[], characterStyles[], paragraphStyles[]
│ ├── variables[], datasets[]
│ └── inkList[], printOptions
├── preferences
├── printerList[]
└── textFonts[]
Top-Level Objects
- Application (
app): The root object. Provides access to documents, preferences, fonts, and printers. Key properties: activeDocument, documents, textFonts, printerList, userInteractionLevel, version.
- Document: Represents an open
.ai file. Key properties: layers, pageItems, selection, activeLayer, width, height, rulerOrigin, documentColorSpace. Key methods: saveAs(), exportFile(), close(), print().
- Layer: A drawing layer. Key properties:
pageItems, pathItems, textFrames, visible, locked, opacity, name, zOrderPosition, color.
Measurement Units and Coordinates
Units
All scripting API values use points (72 points = 1 inch). Convert other units:
| Unit |
Conversion |
| Inches |
multiply by 72 |
| Centimeters |
multiply by 28.346 |
| Millimeters |
multiply by 2.834645 |
| Picas |
multiply by 12 |
Kerning, tracking, and aki properties use em units (thousandths of an em, proportional to font size).
Coordinate System
- For scripted documents, the origin
(0,0) is at the bottom-left of the artboard
- X increases left to right; Y increases bottom to top
- The
position property of a page item is the top-left corner of its bounding box as [x, y]
- Maximum page item width/height: 16348 points
Art Item Bounds
Every page item has three bounding rectangles:
geometricBounds: Excludes stroke width [left, top, right, bottom]
visibleBounds: Includes stroke width
controlBounds: Includes control/direction points
Working with Documents
Creating and Opening
// Create a new document
var doc = app.documents.add();
// Create with a preset
var preset = new DocumentPreset();
preset.width = 612; // 8.5 inches
preset.height = 792; // 11 inches
preset.colorMode = DocumentColorSpace.CMYK;
var doc = app.documents.addDocument("Print", preset);
// Open an existing file
var fileRef = new File("/path/to/file.ai");
var doc = app.open(fileRef);
Saving and Exporting
// Save as Illustrator format
var saveOpts = new IllustratorSaveOptions();
saveOpts.compatibility = Compatibility.ILLUSTRATOR17; // CC
doc.saveAs(new File("/path/to/output.ai"), saveOpts);
// Export as PDF
var pdfOpts = new PDFSaveOptions();
pdfOpts.compatibility = PDFCompatibility.ACROBAT7;
pdfOpts.preserveEditability = false;
doc.saveAs(new File("/path/to/output.pdf"), pdfOpts);
// Export as PNG
var pngOpts = new ExportOptionsPNG24();
pngOpts.horizontalScale = 300;
pngOpts.verticalScale = 300;
pngOpts.transparency = true;
doc.exportFile(new File("/path/to/output.png"), ExportType.PNG24, pngOpts);
// Export as SVG
var svgOpts = new ExportOptionsSVG();
svgOpts.fontType = SVGFontType.OUTLINEFONT;
doc.exportFile(new File("/path/to/output.svg"), ExportType.SVG, svgOpts);
Working with Paths and Shapes
Built-in Shape Methods
The pathItems collection provides convenience methods for common shapes:
var doc = app.activeDocument;
var layer = doc.activeLayer;
// Rectangle: rectangle(top, left, width, height)
var rect = layer.pathItems.rectangle(500, 100, 200, 150);
// Rounded rectangle: roundedRectangle(top, left, width, height, hRadius, vRadius)
var rrect = layer.pathItems.roundedRectangle(500, 100, 200, 150, 20, 20);
// Ellipse: ellipse(top, left, width, height)
var oval = layer.pathItems.ellipse(400, 200, 100, 100);
// Polygon: polygon(centerX, centerY, radius, sides)
var hex = layer.pathItems.polygon(300, 300, 50, 6);
// Star: star(centerX, centerY, radius, innerRadius, points)
var star = layer.pathItems.star(300, 300, 50, 25, 5);
Extended reference
Additional detailed guidance was moved to references/extended-guide.md to keep this skill within the progressive-disclosure budget.
Progressive disclosure and bundled resources
references/object-model-quick-reference.md: quick lookup for the Illustrator object model and common DOM types.
references/extended-guide.md: extended guidance that was moved out of SKILL.md for progressive disclosure.
scripts/: example Illustrator automation scripts for document manipulation, exports, batch processing, and DOM usage.
Output template
## Illustrator scripting result
**Status:** implemented | reviewed | blocked
**Target:** `{{script_or_document}}`
### Script or patch
```javascript
#target illustrator
{{jsx_code}}
```
### Validation
- `{{execution_path}}`: pass | fail
- DOM objects used: `{{Application}}`, `{{Document}}`, `{{Layer}}`, `{{PathItem}}`, `{{TextFrame}}` as applicable
- Export or save output: `{{file_path_or_none}}`
Quality gate
1---2name: adobe-illustrator-scripting3description: Write, debug, and optimize Adobe Illustrator automation scripts using ExtendScript (JavaScript/JSX). Use when creating or modifying scripts that manipulate documents, layers, paths, text frames, colors, symbols, artboards, or any Illustrator DOM objects. Covers the complete JavaScript object model, coordinate system, measurement units, export workflows, and scripting best practices.4---56<!-- Generated from harness/github-copilot/skills/adobe-illustrator-scripting/SKILL.md by harness/claude-code/scripts/convert_from_copilot.py. Edit the source, not this file. -->78# Adobe Illustrator scripting910Write, debug, and optimize Adobe Illustrator ExtendScript automation by applying the Illustrator DOM, coordinate system, document and page item APIs, export options, and bundled JSX patterns.1112## When to invoke1314- "Write an Illustrator JSX script."15- "Debug this Adobe Illustrator ExtendScript."16- "Automate Illustrator layers, paths, text, colors, symbols, or artboards."17- "Export Illustrator documents to PDF, SVG, PNG, or EPS with a script."18- "Batch process .ai files with JavaScript."1920Expert guidance for automating Adobe Illustrator through ExtendScript (JavaScript/JSX). This skill covers the Illustrator scripting object model, all major API objects, code patterns, and best practices for writing production-quality `.jsx` scripts.2122## Bundled Assets2324- [`references/object-model-quick-reference.md`](references/object-model-quick-reference.md): Use this as a quick lookup for the Illustrator scripting object model, common document and page item types, and related DOM concepts while writing or debugging scripts.25- `scripts/`: Contains example Illustrator automation scripts you can use as starting points or implementation patterns for common tasks such as document manipulation, exports, batch processing, and DOM usage. Review and adapt these examples when you need working JSX patterns or want to compare behavior while debugging.26## Invocation details2728- Writing new Illustrator automation scripts (`.jsx` or `.js` files)29- Debugging or fixing existing Illustrator ExtendScript code30- Manipulating documents, layers, page items, paths, text, or colors programmatically31- Batch-processing Illustrator files or generating artwork from data32- Exporting documents to various formats (PDF, SVG, PNG, EPS, etc.)33- Working with the Illustrator DOM (Application, Document, Layer, PathItem, TextFrame, etc.)34- Creating data-driven graphics using variables and datasets35- Automating print workflows with scripted print options3637## Prerequisites3839- Adobe Illustrator CC or later installed40- Basic JavaScript knowledge (ExtendScript is ES3-based with Adobe extensions)41- Scripts are executed via File > Scripts > Other Scripts, the Scripts menu, or placed in the Startup Scripts folder42- The ExtendScript Toolkit (ESTK) or any text editor can be used to write `.jsx` files4344## Scripting Environment4546### Language and File Extensions4748| Language | Extension | Platform |49|---|---|---|50| ExtendScript/JavaScript | `.jsx`, `.js` | Windows, macOS |51| AppleScript | `.scpt` | macOS only |52| VBScript | `.vbs` | Windows only |5354**This skill focuses on ExtendScript/JavaScript** as the cross-platform, most widely used option.5556### Executing Scripts5758- **Scripts menu**: File > Scripts lists scripts from the application scripts folder59- **Other Scripts**: File > Scripts > Other Scripts to browse and run any `.jsx` file60- **Startup Scripts**: Place scripts in the Startup Scripts folder to run automatically on launch61- **Target directive**: Begin scripts with `#target illustrator` when running from ESTK or external tools62- **`#targetengine` directive**: Use `#targetengine "session"` to persist variables across script executions63- **External invocation**: Scripts are frequently launched from outside Illustrator — by shell scripts, task runners, CI jobs, ExtendScript Toolkit (`ExtendScript Toolkit.exe -run script.jsx`), or `BridgeTalk` messages from other Adobe apps. See [External Invocation & Argument Passing](#external-invocation--argument-passing).6465### Naming Conventions (JavaScript)6667- Objects and properties use **camelCase**: `activeDocument`, `pathItems`, `textFrames`68- The `app` global references the `Application` object69- Collection indices are **zero-based**: `documents[0]` is the frontmost document70- Use `typename` property to identify object types at runtime7172## Object Model Overview7374The Illustrator DOM follows a strict containment hierarchy:7576```77Application (app)78├── activeDocument / documents[]79│ ├── layers[]80│ │ ├── pageItems[] (all artwork)81│ │ ├── pathItems[]82│ │ ├── compoundPathItems[]83│ │ ├── textFrames[]84│ │ ├── placedItems[]85│ │ ├── rasterItems[]86│ │ ├── meshItems[]87│ │ ├── pluginItems[]88│ │ ├── graphItems[]89│ │ ├── symbolItems[]90│ │ ├── nonNativeItems[]91│ │ ├── legacyTextItems[]92│ │ └── groupItems[]93│ ├── artboards[]94│ ├── views[]95│ ├── selection (array of selected items)96│ ├── swatches[], spots[], gradients[], patterns[]97│ ├── graphicStyles[], brushes[], symbols[]98│ ├── textFonts[] (via app.textFonts)99│ ├── stories[], characterStyles[], paragraphStyles[]100│ ├── variables[], datasets[]101│ └── inkList[], printOptions102├── preferences103├── printerList[]104└── textFonts[]105```106107### Top-Level Objects108109- **Application** (`app`): The root object. Provides access to documents, preferences, fonts, and printers. Key properties: `activeDocument`, `documents`, `textFonts`, `printerList`, `userInteractionLevel`, `version`.110- **Document**: Represents an open `.ai` file. Key properties: `layers`, `pageItems`, `selection`, `activeLayer`, `width`, `height`, `rulerOrigin`, `documentColorSpace`. Key methods: `saveAs()`, `exportFile()`, `close()`, `print()`.111- **Layer**: A drawing layer. Key properties: `pageItems`, `pathItems`, `textFrames`, `visible`, `locked`, `opacity`, `name`, `zOrderPosition`, `color`.112113## Measurement Units and Coordinates114115### Units116117All scripting API values use **points** (72 points = 1 inch). Convert other units:118119| Unit | Conversion |120|---|---|121| Inches | multiply by 72 |122| Centimeters | multiply by 28.346 |123| Millimeters | multiply by 2.834645 |124| Picas | multiply by 12 |125126Kerning, tracking, and `aki` properties use **em units** (thousandths of an em, proportional to font size).127128### Coordinate System129130- For **scripted documents**, the origin `(0,0)` is at the **bottom-left** of the artboard131- X increases left to right; Y increases bottom to top132- The `position` property of a page item is the **top-left corner** of its bounding box as `[x, y]`133- Maximum page item width/height: 16348 points134135### Art Item Bounds136137Every page item has three bounding rectangles:138139- `geometricBounds`: Excludes stroke width `[left, top, right, bottom]`140- `visibleBounds`: Includes stroke width141- `controlBounds`: Includes control/direction points142143## Working with Documents144145### Creating and Opening146147```javascript148// Create a new document149var doc = app.documents.add();150151// Create with a preset152var preset = new DocumentPreset();153preset.width = 612; // 8.5 inches154preset.height = 792; // 11 inches155preset.colorMode = DocumentColorSpace.CMYK;156var doc = app.documents.addDocument("Print", preset);157158// Open an existing file159var fileRef = new File("/path/to/file.ai");160var doc = app.open(fileRef);161```162163### Saving and Exporting164165```javascript166// Save as Illustrator format167var saveOpts = new IllustratorSaveOptions();168saveOpts.compatibility = Compatibility.ILLUSTRATOR17; // CC169doc.saveAs(new File("/path/to/output.ai"), saveOpts);170171// Export as PDF172var pdfOpts = new PDFSaveOptions();173pdfOpts.compatibility = PDFCompatibility.ACROBAT7;174pdfOpts.preserveEditability = false;175doc.saveAs(new File("/path/to/output.pdf"), pdfOpts);176177// Export as PNG178var pngOpts = new ExportOptionsPNG24();179pngOpts.horizontalScale = 300;180pngOpts.verticalScale = 300;181pngOpts.transparency = true;182doc.exportFile(new File("/path/to/output.png"), ExportType.PNG24, pngOpts);183184// Export as SVG185var svgOpts = new ExportOptionsSVG();186svgOpts.fontType = SVGFontType.OUTLINEFONT;187doc.exportFile(new File("/path/to/output.svg"), ExportType.SVG, svgOpts);188```189190## Working with Paths and Shapes191192### Built-in Shape Methods193194The `pathItems` collection provides convenience methods for common shapes:195196```javascript197var doc = app.activeDocument;198var layer = doc.activeLayer;199200// Rectangle: rectangle(top, left, width, height)201var rect = layer.pathItems.rectangle(500, 100, 200, 150);202203// Rounded rectangle: roundedRectangle(top, left, width, height, hRadius, vRadius)204var rrect = layer.pathItems.roundedRectangle(500, 100, 200, 150, 20, 20);205206// Ellipse: ellipse(top, left, width, height)207var oval = layer.pathItems.ellipse(400, 200, 100, 100);208209// Polygon: polygon(centerX, centerY, radius, sides)210var hex = layer.pathItems.polygon(300, 300, 50, 6);211212// Star: star(centerX, centerY, radius, innerRadius, points)213var star = layer.pathItems.star(300, 300, 50, 25, 5);214```215## Extended reference216217Additional detailed guidance was moved to [references/extended-guide.md](references/extended-guide.md) to keep this skill within the progressive-disclosure budget.218219## Progressive disclosure and bundled resources220221- `references/object-model-quick-reference.md`: quick lookup for the Illustrator object model and common DOM types.222- `references/extended-guide.md`: extended guidance that was moved out of SKILL.md for progressive disclosure.223- `scripts/`: example Illustrator automation scripts for document manipulation, exports, batch processing, and DOM usage.224225## Output template226227````markdown228## Illustrator scripting result229230**Status:** implemented | reviewed | blocked231**Target:** `{{script_or_document}}`232233### Script or patch234```javascript235#target illustrator236{{jsx_code}}237```238239### Validation240- `{{execution_path}}`: pass | fail241- DOM objects used: `{{Application}}`, `{{Document}}`, `{{Layer}}`, `{{PathItem}}`, `{{TextFrame}}` as applicable242- Export or save output: `{{file_path_or_none}}`243````244245## Quality gate246247- [ ] The solution uses ExtendScript/JavaScript APIs that Illustrator supports, not browser-only JavaScript.248- [ ] All measurement values are converted to points where the Illustrator DOM expects points.249- [ ] Coordinates account for Illustrator's scripted-document origin and page item `position` semantics.250- [ ] Exports use the correct options object and `doc.saveAs()` or `doc.exportFile()` method.251- [ ] Bundled references or scripts are consulted when detailed API lookup or working JSX examples are needed.