npx skills add ...
npx skills add github/awesome-copilot --skill adobe-illustrator-scripting
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.
npx skills add github/awesome-copilot --skill adobe-illustrator-scripting
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.
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..jsx or .js files).jsx files| 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.
.jsx file#target illustrator when running from ESTK or external tools#targetengine directive: Use #targetengine "session" to persist variables across script executionsExtendScript Toolkit.exe -run script.jsx), or BridgeTalk messages from other Adobe apps. See External Invocation & Argument Passing.activeDocument, pathItems, textFramesapp global references the Application objectdocuments[0] is the frontmost documenttypename property to identify object types at runtimeThe Illustrator DOM follows a strict containment hierarchy:
app): The root object. Provides access to documents, preferences, fonts, and printers. Key properties: activeDocument, documents, textFonts, printerList, userInteractionLevel, version..ai file. Key properties: layers, pageItems, selection, activeLayer, width, height, rulerOrigin, documentColorSpace. Key methods: saveAs(), exportFile(), close(), print().pageItems, pathItems, textFrames, visible, locked, opacity, name, zOrderPosition, color.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).
(0,0) is at the bottom-left of the artboardposition property of a page item is the top-left corner of its bounding box as [x, y]Every page item has three bounding rectangles:
geometricBounds: Excludes stroke width [left, top, right, bottom]visibleBounds: Includes stroke widthcontrolBounds: Includes control/direction pointsThe pathItems collection provides convenience methods for common shapes:
Control whether Illustrator shows dialogs during script execution:
When calling methods with multiple optional parameters, use undefined to skip middle parameters:
Illustrator scripts are routinely launched from outside the application —
shell scripts, schedulers, build pipelines, ExtendScript Toolkit, or
BridgeTalk messages from other Creative Cloud apps. The execution
environment under those launchers differs from the in-application File >
Scripts path in several ways that frequently break otherwise-correct code.
arguments[] Is Unreliable Under External LaunchersExtendScript Toolkit's -run invocation and BridgeTalk.send() do not
forward arbitrary launcher arguments into the script's top-level
arguments[] array. In many configurations the array contains a single
[object BridgeTalk] element instead of the values the caller passed, as
demonstrated below:
Do not rely on arguments[] for required inputs when the script is
launched externally. Use one of the following more reliable channels.
When a script fails under an external launcher and the source of the error is not obvious, fall back to a sidecar file: have the caller write a small text file at a known absolute path, and read it on startup. This works regardless of launcher quirks and is easy to inspect after a failed run.
A key=value format is equally workable and avoids positional fragility:
$.getenv("NAME") returns environment variables visible to Illustrator's
process, not the launcher's. If the launcher needs Illustrator to see a
value, it must set the variable system-wide or in Illustrator's parent
environment before launching. For per-invocation values, prefer a sidecar
file.
$.fileName and File($.fileName).parentUnder in-application execution, $.fileName is the absolute path of the
running script and File($.fileName).parent yields the script's folder.
Under some external launchers (notably ESTK -run) $.fileName can be
empty, causing relative path resolution to silently fail.
Silent failures are common because dialogs are suppressed and the launcher
may not surface $.writeln output. Write a plain-text log to a known
absolute path so a run can be inspected after the fact. Create the parent
folder on demand so the first call cannot fail for a missing directory.
try { ... } catchExternally launched scripts often fail without any visible indication. A
top-level try/catch that writes the error to the log file converts
silent failures into a single inspectable line.
External callers cannot answer dialogs. Disable them before any DOM work
and avoid alert() / confirm() / prompt() entirely in scripts that may
be launched headlessly.
Closing or letting Illustrator return to its idle state does not save the
working file. After all DOM edits, call doc.saveAs(...) (or doc.save())
explicitly and log whether it succeeded.
A locked layer or any locked ancestor (parent group, clip group, sublayer)
will cause edits to throw Error: Target layer cannot be modified. Walk the
full hierarchy and clear locked / hidden flags before performing DOM
modifications.
PlacedItem.file = newFile replaces a linked image while preserving the
parent, stacking order, and (after re-applying) the bounds. RasterItem
does not expose a writable file property, so when a placeholder is a
raster you must add a fresh PlacedItem in the same parent, copy the bounds,
then remove the original.
PlacedItem.file accepts raster formats and AI/PDF, but not SVG. Setting
it to an .svg File throws Unable to set placed item's file, is the file path provided valid?. The reliable way to bring SVG artwork into a document
is to open the SVG as a separate document, select all, copy, close, and paste
into the working document.
Clip groups expose their clipping shape as a child PathItem (or, less
commonly, a child of a CompoundPathItem) with clipping === true. The
clip's geometricBounds give the visible frame to size or center content
against.
To make an image fully cover a rectangle (any overflow hidden by a mask), use
the larger of the width/height ratios. To make it fit entirely inside, use
the smaller. A bleed factor (e.g. 1.10) lets a cover image extend slightly
past the clip edge.
.length before accessing items.app.redraw() to force a screen refresh after modifications.doc.documentColorSpace to check.position property is the top-left of the bounding box.position; for area text, provide a valid path to areaText()./) or double backslashes (\\) in path strings, or use the File object constructor.app.userInteractionLevel = UserInteractionLevel.DONTDISPLAYALERTS before batch operations.getByName(): Many collection objects support getByName("name") which throws an error if not found; wrap in try/catch.Cover_Mask) is blocking the edit. Recursively clear locked and hidden across the document before modifying. See Recursively Unlock Layers and Groups.PlacedItem.file does not accept the format. SVG is the most common cause — use the open / copy / paste pattern instead.RasterItem.file = newFile does nothing or throws: RasterItem does not expose a writable file property. Add a new PlacedItem to the same parent, restore the bounds and name, then .remove() the raster.arguments[0] is [object BridgeTalk] (or empty): The script was launched through ESTK -run or a BridgeTalk message; positional arguments are not forwarded. Use a sidecar file at a known absolute path. See External Invocation & Argument Passing.$.fileName is empty: Same external-launcher cause. Do not derive resource paths from $.fileName in scripts that may be invoked headlessly — use absolute paths or Folder.temp.saveAs after edits. Add a top-level try/catch that logs to an absolute path to confirm execution and capture the error.item.resize(sx, sy) recentered the artwork unexpectedly: resize defaults to scaling around the item's center (Transformation.CENTER). Pass an explicit scaleAbout argument or follow with translate(dx, dy) to reposition.Common enumeration constants used across the API:
| Category | Constants |
|---|---|
| Color Space | DocumentColorSpace.RGB, DocumentColorSpace.CMYK |
| Justification | Justification.LEFT, Justification.CENTER, Justification.RIGHT, Justification.FULLJUSTIFY |
| Point Type | PointType.SMOOTH, PointType.CORNER |
| Stroke Cap | StrokeCap.BUTTENDCAP, StrokeCap.ROUNDENDCAP, StrokeCap.PROJECTINGENDCAP |
| Stroke Join | StrokeJoin.MITERENDJOIN, StrokeJoin.ROUNDENDJOIN, StrokeJoin.BEVELENDJOIN |
| Blend Mode | BlendModes.NORMAL, BlendModes.MULTIPLY, BlendModes.SCREEN, BlendModes.OVERLAY |
| Save Options | SaveOptions.SAVECHANGES, SaveOptions.DONOTSAVECHANGES, SaveOptions.PROMPTTOSAVECHANGES |
| Export Type | ExportType.PNG24, ExportType.PNG8, ExportType.JPEG, ExportType.SVG, ExportType.TIFF, ExportType.PHOTOSHOP, ExportType.AUTOCAD, ExportType.FLASH |
| Element Placement | ElementPlacement.PLACEATBEGINNING, ElementPlacement.PLACEATEND, ElementPlacement.PLACEBEFORE, ElementPlacement.PLACEAFTER, ElementPlacement.INSIDE |
| Z-Order | ZOrderMethod.BRINGTOFRONT, ZOrderMethod.SENDTOBACK, ZOrderMethod.BRINGFORWARD, ZOrderMethod.SENDBACKWARD |
| Gradient Type | GradientType.LINEAR, GradientType.RADIAL |
| Text Frame Kind | TextType.POINTTEXT, TextType.AREATEXT, TextType.PATHTEXT |
| Variable Kind | VariableKind.TEXTUAL, VariableKind.IMAGE, VariableKind.VISIBILITY, VariableKind.GRAPH |
| User Interaction | UserInteractionLevel.DISPLAYALERTS, UserInteractionLevel.DONTDISPLAYALERTS |
| Compatibility | Compatibility.ILLUSTRATOR10 through Compatibility.ILLUSTRATOR24 |
The Illustrator JavaScript API contains the following objects, grouped by category:
Application, Document, Documents, DocumentPreset, Layer, Layers, PageItem, PageItems, View, Views, Preferences
PathItem, PathItems, PathPoint, PathPoints, CompoundPathItem, CompoundPathItems, GroupItem, GroupItems
TextFrame, TextRange, TextRanges, TextPath, Characters, Words, Paragraphs, Lines, InsertionPoint, InsertionPoints, Story, Stories, CharacterAttributes, ParagraphAttributes, CharacterStyle, CharacterStyles, ParagraphStyle, ParagraphStyles, TextFont, TextFonts, TabStopInfo
RGBColor, CMYKColor, GrayColor, LabColor, NoColor, SpotColor, Spot, Spots, PatternColor, GradientColor, Color, Gradient, Gradients, GradientStop, GradientStops
Swatch, Swatches, SwatchGroup, SwatchGroups, GraphicStyle, GraphicStyles, Pattern, Patterns, Brush, Brushes
Symbol, Symbols, SymbolItem, SymbolItems
Artboard, Artboards
PlacedItem, PlacedItems, RasterItem, RasterItems, MeshItem, MeshItems, GraphItem, GraphItems, PluginItem, PluginItems, NonNativeItem, NonNativeItems, LegacyTextItem, LegacyTextItems
Variable, Variables, Dataset, Datasets
Matrix
Tag, Tags
TracingObject, TracingOptions
IllustratorSaveOptions, EPSSaveOptions, PDFSaveOptions, FXGSaveOptions, ExportOptionsAutoCAD, ExportOptionsFlash, ExportOptionsGIF, ExportOptionsJPEG, ExportOptionsPhotoshop, ExportOptionsPNG8, ExportOptionsPNG24, ExportOptionsSVG, ExportOptionsTIFF
OpenOptions, OpenOptionsAutoCAD, OpenOptionsFreeHand, OpenOptionsPhotoshop, PDFFileOptions, PhotoshopFileOptions
PrintOptions, PrintJobOptions, PrintPaperOptions, PrintColorManagementOptions, PrintColorSeparationOptions, PrintCoordinateOptions, PrintFlattenerOptions, PrintFontOptions, PrintPageMarksOptions, PrintPostScriptOptions, Printer, PrinterInfo, Paper, PaperInfo, PPDFile, PPDFileInfo, Ink, InkInfo, Screen, ScreenInfo, ScreenSpotFunction
ImageCaptureOptions, RasterEffectOptions, RasterizeOptions
Document.getPageItemFromUuid and PageItem.uuid; CC 2017 added Application.getIsFileOpen)