Skip to content

Document

app.activeDocument

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 fillColor and 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.open() for more information on how document color spaces are handled.


app.activeDocument.activeDataset

The currently opened dataset.

Dataset


app.activeDocument.activeLayer

The active layer in the document.

Layer


app.activeDocument.activeView

The document’s current view.

View; read-only.


app.activeDocument.artboards

All artboards in the document.

Artboards; read-only.


app.activeDocument.brushes

The brushes contained in the document.

Brushes; read-only.


app.activeDocument.characterStyles

The list of character styles in this document.

CharacterStyles; read-only.


app.activeDocument.compoundPathItems

The compound path items contained in the document.

CompoundPathItems; read-only.


app.activeDocument.cropBox

The boundary of the document’s cropping box for output, or null if no value has been set.

Array of 4 numbers.


app.activeDocument.cropStyle

The style of the document’s cropping box.

CropOptions


app.activeDocument.dataSets

The datasets contained in the document.

Datasets; read-only.


app.activeDocument.defaultFillColor

The color to use to fill new paths if defaultFilled is true.

Color


app.activeDocument.defaultFilled

If true, a new path should be filled.

Boolean.


app.activeDocument.defaultFillOverprint

If true, the art beneath a filled object should be overprinted by default.

Boolean.


app.activeDocument.defaultStrokeCap

Default type of line capping for paths created.

StrokeCap


app.activeDocument.defaultStrokeColor

The stroke color for new paths if default stroked is true.

Color


app.activeDocument.defaultStroked

If true, a new path should be stroked.

Boolean.


app.activeDocument.defaultStrokeDashes

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.

Object.


app.activeDocument.defaultStrokeDashOffset

The default distance into the dash pattern at which the pattern should be started for new paths.

Number (double).


app.activeDocument.defaultStrokeJoin

Default type of joints in new paths.

StrokeJoin


app.activeDocument.defaultStrokeMiterLimit

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.

Number (double).


app.activeDocument.defaultStrokeOverprint

If true, the art beneath a stroked object should be overprinted by default.

Boolean.


app.activeDocument.defaultStrokeWidth

Default width of stroke for new paths.

Number (double).


app.activeDocument.documentColorSpace

The color specification system to use for this document’s color space.

DocumentColorSpace


app.activeDocument.fullName

The file associated with the document, which includes the complete path to the file.

File object; read-only.


app.activeDocument.geometricBounds

The bounds of the illustration excluding the stroke width of any objects in the document.

Array of 4 numbers; read-only.


app.activeDocument.gradients

The gradients contained in the document.

Gradients; read-only.


app.activeDocument.graphicStyles

The graphic styles defined in this document.

GraphicStyles; read-only.


app.activeDocument.graphItems

The graph art items in this document.

GraphItems; read-only.


app.activeDocument.groupItems

The group items contained in the document.

GroupItems; read-only.


app.activeDocument.height

The height of the document.

Number (double); read-only.


app.activeDocument.inkList

The list of inks in this document.

Object; read-only.


app.activeDocument.kinsokuSet

The Kinsoku set of characters that cannot begin or end a line of Japanese text.

Object; read-only.


app.activeDocument.layers

The layers contained in the document.

Layers; read-only.


app.activeDocument.legacyTextItems

The legacy text items in the document.

LegacyTextItems; read-only.


app.activeDocument.meshItems

The mesh art items contained in the document.

MeshItems; read-only.


app.activeDocument.mojikumiSet

A list of names of predefined Mojikumi sets which specify the spacing for the layout and composition of Japanese text.

Object; read-only.


app.activeDocument.name

The document’s name (not the complete file path to the document).

String; read-only.


app.activeDocument.nonNativeItems

The non-native art items in this document.

NonNativeItems; read-only.


app.activeDocument.outputResolution

The current output resolution for the document in dots per inch (dpi).

Number (double); read-only.


app.activeDocument.pageItems

The page items (all art item classes) contained in the document.

PageItems; read-only.


app.activeDocument.pageOrigin

The zero-point of the page in the document without margins, relative to the overall height and width.

Array of 2 numbers.


app.activeDocument.paragraphStyles

The list of paragraph styles in this document.

ParagraphStyles; read-only.


app.activeDocument.parent

The application that contains this document.

Application; read-only.


app.activeDocument.path

The file associated with the document, which includes the complete path to the file.

File object; read-only.


app.activeDocument.pathItems

The path items contained in this document.

PathItems; read-only.


app.activeDocument.patterns

The patterns contained in this document.

Patterns; read-only.


app.activeDocument.placedItems

The placed items contained in this document.

PlacedItems; read-only.


app.activeDocument.pluginItems

The plug-in items contained in this document.

PluginItems; read-only.


app.activeDocument.printTiles

If true, this document should be printed as tiled output.

Boolean; read-only.


app.activeDocument.rasterEffectSettings

The document’s raster effect settings.

RasterEffectOptions; read-only.


app.activeDocument.rasterItems

The raster items contained in this document.

RasterItems; read-only.


app.activeDocument.rulerOrigin

The zero-point of the rulers in the document relative to the bottom left of the document.

Array of 2 numbers.


app.activeDocument.rulerUnits

The default measurement units for the rulers in the document.

RulerUnits; read-only.


app.activeDocument.saved

If true, the document has not been changed since last time it was saved.

Boolean.


app.activeDocument.selection

References to the objects in this document’s current selection, or null when nothing is selected.

A reference to an insertion point is returned when there is an active insertion point in the contents of a selected text art item. Similarly, a reference to a range of text is returned when characters are selected in the contents of a text art item.

Array of objects.


app.activeDocument.showPlacedImages

If true, placed images should be displayed in the document.

Boolean; read-only.


app.activeDocument.splitLongPaths

If true, long paths should be split when printing.

Boolean; read-only.


app.activeDocument.spots

The spot colors contained in this document.

Spots; read-only.


app.activeDocument.stationery

If true, the file is a stationery file.

Boolean; read-only.


app.activeDocument.stories

The story items in this document.

Stories; read-only.


app.activeDocument.swatches

The swatches in this document.

Swatches; read-only.


app.activeDocument.swatchGroups

The swatch groups in this document.

SwatchGroups; read-only.


app.activeDocument.symbolItems

The art items in the document linked to symbols.

SymbolItems; read-only.


app.activeDocument.symbols

The symbols in this document.

Symbols; read-only.


app.activeDocument.tags

The tags in this document.

Tags; read-only.


app.activeDocument.textFrames

The text frames in this document.

TextFrameItems; read-only.


app.activeDocument.tileFullPages

If true, full pages should be tiled when printing this document.

Boolean; read-only.


app.activeDocument.typename

The class name of the referenced object.

String; read-only.


app.activeDocument.useDefaultScreen

If true, the printer’s default screen should be used when printing this document.

Boolean; read-only.


app.activeDocument.variables

The variables defined in this document.

Variables; read-only.


app.activeDocument.variablesLocked

If true, the variables are locked.

Boolean.


app.activeDocument.views

The views contained in this document.

Views; read-only.


app.activeDocument.visibleBounds

The visible bounds of the document, including stroke width of any objects in the illustration.

Array of 4 numbers; read-only.


app.activeDocument.width

The width of this document.

Number (double); read-only.


app.activeDocument.XMPString

The XMP metadata packet associated with this document.

String.


app.activeDocument.activate()

Brings the first window associated with the document to the front.

Nothing.


app.activeDocument.arrange([layoutStyle])

Arranges multiple documents in the given layout style.

ParameterTypeDescription
layoutStyleDocumentLayoutStyle, optionalThe layout style to arrange documents in

Boolean.


app.activeDocument.close([saveOptions])

Closes a document using specified save options.

When you close a document, you should set your document reference to null to prevent your script from accidentally trying to access closed documents.

ParameterTypeDescription
saveOptionsSaveOptionsSave options to close with

Nothing.


app.activeDocument.closeNoUI()

Closes the specified non-UI document.

Nothing.


app.activeDocument.convertCoordinate(coordinate, source, destination)

Converts the given point between artboard and document coordinate systems. Returns the converted point coordinates.

ParameterTypeDescription
coordinatePointPoint to convert
sourceCoordinateSystemSource coordinate system
destinationCoordinateSystemDestination coordinate system

Point.


app.activeDocument.exportFile(exportFile, exportFormat [,options])

Exports the document to the specified file using one of the predefined export file formats. The appropriate file extension is automatically appended to the file name, except for Photoshop® documents. For these, you must include the file extension (PSD) in the file specification.

ParameterTypeDescription
exportFileFile objectFile to save
exportFormatExportTypeExport file format
optionsVariable, optionaltodo

Nothing.


app.activeDocument.exportPDFPreset(file)

Exports the current PDF preset values to the file.

ParameterTypeDescription
fileFile objectPreset file to export to

Nothing.


app.activeDocument.exportPerspectiveGridPreset(file)

Exports the current perspective grid preset values to the file.

ParameterTypeDescription
fileFile objectPreset file to export to

Nothing.


app.activeDocument.exportPrintPreset(file)

Exports the current print preset values to the file.

ParameterTypeDescription
fileFile objectPreset file to export to

Nothing.


app.activeDocument.exportVariables(fileSpec)

Saves datasets into an XML library. The datasets contain variables and their associated dynamic data.

ParameterTypeDescription
fileSpecFile objectXML Library file to export to

Nothing.


app.activeDocument.fitArtboardToSelectedArt([index])

Resizes the artboard at the given index to fit currently selected art. Index default is 0. Returns true on success.

ParameterTypeDescription
indexNumber (long), optionalArtboard index to resize

Boolean.


app.activeDocument.getPageItemFromUuid(uuid)

Retrieves the PageItem using its Uuid.

ParameterTypeDescription
uuidStringuuid of item to fetch

PageItem.


app.activeDocument.getPerspectiveActivePlane()

Retrieves the active plane of the active perspective grid of the document.

PerspectiveGridPlaneType


app.activeDocument.hidePerspectiveGrid()

Hides the current active grid for the document. If no grid is visible, does nothing.

Returns true if a grid is hidden.

Boolean.


app.activeDocument.imageCapture(imageFile [,clipBounds] [,options])

Captures the artwork content within the clipping boundaries in this document as a raster image, and writes the image data to a specified file.

If the bounds parameter is omitted, captures the entire artwork.

ParameterTypeDescription
imageFile File objectImage file to write to
clipBoundsRect, optionalClipping bounds
optionsImageCaptureOptions, optionaltodo

Nothing.


app.activeDocument.importCharacterStyles(fileSpec)

Loads the character styles from the Illustrator file.

ParameterTypeDescription
fileSpec File objectFile to load character styles from

Nothing.


app.activeDocument.importParagraphStyles(fileSpec)

Loads the paragraph styles from the Illustrator file.

ParameterTypeDescription
fileSpecFile objectFile to load paragraph styles from

Nothing.


app.activeDocument.importPDFPreset(fileSpec [, replacingPreset])

Loads all PDF presets from a file.

ParameterTypeDescription
fileSpecFile objectFile to load PDF presets from
replacingPresetString, optionalWhether to replace existing presets

Nothing.


app.activeDocument.importPrintPreset(printPreset, fileSpec)

Loads the named print preset from the file.

ParameterTypeDescription
printPresetStringName of preset to load
fileSpecFile objectFile to load print presets from

Nothing.


app.activeDocument.importVariables(fileSpec)

Imports a library containing datasets, variables, and their associated dynamic data. Importing variables overwrites existing variables and datasets.

ParameterTypeDescription
fileSpecFile objectFile to import variables from

Nothing.


app.activeDocument.print([options])

Prints the document.

ParameterTypeDescription
optionsPrintOptions, optionaltodo

Nothing.


app.activeDocument.rasterize(sourceArt [, clipBounds] [, options])

Rasterizes the source art(s) within the specified clip bounds. The source art(s) is disposed of as a result of the rasterization.

ParameterTypeDescription
sourceArtVariableSource art to rasterize
clipBoundsRect, optionalClipping bounds
optionsRasterizeOptions, optionaltodo

RasterItem


app.activeDocument.rearrangeArboards([artboardLayout] [, artboardRowsOrCols] [, artboardSpacing] [, artboardMoveArtwork])

Rearranges artboards in the document. All arguments are optional.

Default layout style is DocumentArtboard Layout.GridByRow.

The second argument specifies the number of rows or columns, as appropriate for the chosen layout style, in the range 1..docNumArtboards-1, or 1 (the default) for single row/column layouts.

Spacing is a number of pixels, default 20.

When last argument is true (the default), artwork is moved with the artboards.

ParameterTypeDescription
artboardLayoutDocumentArtboardLayout, optionalArtboard layout
artboardRowsOrColsInteger, optionalNumber of rows or columns
artboardSpacingNumber, optionalNumber of pixels for spacing
artboardMoveArtworkBoolean, optionalWhether to move artwork with the artboards

Boolean.


app.activeDocument.save()

Saves the document in it current location.

Nothing.


app.activeDocument.saveAs(saveIn [, options])

Saves the document in the specified file as an Illustrator, EPS, or PDF file.

ParameterTypeDescription
saveInFile objectFile to save the document as
optionsSaveOptions, optionalSave options to close with

Nothing.


app.activeDocument.saveNoUI(saveIn)

Saves the non-UI document at the specified path

ParameterTypeDescription
saveInFile objectFile to save the document as

Nothing.


app.activeDocument.selectObjectsOnActiveArtboard()

Selects the objects on the currently active artboard. Returns true on success.

Boolean.


app.activeDocument.setActivePlane(gridPlane)

Sets the active plane of the active perspective grid of the document. Returns true on success.

ParameterTypeDescription
gridPlanePerspectiveGridPlaneTypeGrid plane type

Boolean.


app.activeDocument.selectPerspectivePreset(gridType, presetName)

Selects a predefined preset to define grid for the current document. Returns true on success.

ParameterTypeDescription
gridTypePerspectiveGridTypeGrid type
presetNameStringPreset name to select

Boolean.


app.activeDocument.showPerspectiveGrid()

Shows the current active grid for the document, or if no grid is active, shows the default grid. Returns true on success.

Boolean.


app.activeDocument.windowCapture(imageFile, windowSize)

Captures the current document window to the target TIFF image file.

ParameterTypeDescription
imageFileFile objectImage file to save as
windowSizeArray of 2 numbersWindow size

Nothing.


Deselecting all objects in the current document

Section titled “Deselecting all objects in the current document”
var docRef = activeDocument;
docRef.selection = null;

// Closes the active document without saving changes
if ( app.documents.length > 0 ) {
var aiDocument = app.activeDocument;
aiDocument.close( SaveOptions.DONOTSAVECHANGES );
aiDocument = null;
}

// Creates a new document if none exists then sets fill and stroke defaults to true
var doc;
if (app.documents.length == 0) {
doc = app.documents.add();
} else {
doc = app.activeDocument;
}
doc.defaultFilled = true;
doc.defaultStroked = true;