Document

The active containment object for the layers and all other objects in the script; the basic canvas for the file.

Methods:

duplicate, close, convertProfile, changeMode, crop, exportDocument, flipCanvas, importAnnotations, flatten, mergeVisibleLayers, paste, print, printOneCopy, revealAll, rasterizeAllLayers, recordMeasurements, rotateCanvas, resizeCanvas, resizeImage, splitChannels, save, saveAs, suspendHistory, trap, trim, duplicate, autoCount

Objects:

ArtLayer, ArtLayers, BitsPerChannelType, Boolean, Channel, Channels, ColorProfileType, ColorSamplers, CountItems, DocumentInfo, DocumentMode, DocumentPrintSettings, File, Guides, HistoryState, HistoryStates, Layer, LayerComps, LayerSets, Layers, MeasurementScale, Number, PathItems, Selection, String, UnitValue, XMPMetadata

Property Listing

Property

Type

Access

Description

activeChannels

Array of Channel

read/write

The selected channels.

activeHistoryBrushSource

HistoryState

read/write

The history state to use with the history brush.

activeHistoryState

HistoryState

read/write

The current history state for this document.

activeLayer

Layer

read/write

The selected layer.

artLayers

ArtLayers ArtLayer

readonly

The art layers collection in the document.

backgroundLayer

ArtLayer

readonly

The background layer for the document.

bitsPerChannel

BitsPerChannelType

BitsPerChannelType.ONE

BitsPerChannelType.EIGHT

BitsPerChannelType.SIXTEEN

BitsPerChannelType.THIRTYTWO

read/write

The number of bits per channel.

channels

Channels Channel

readonly

The channels collection in this document.

colorProfileName

String

read/write

The name of the color profile. Valid only when no value is specified for color profile kind (to indicate a custom color profile).

colorProfileType

ColorProfileType

ColorProfileType.NONE

ColorProfileType.WORKING

ColorProfileType.CUSTOM

read/write

The type of color model that defines the working space of the document.

colorSamplers

ColorSamplers ColorSampler

readonly

The current color samplers associated with the document.

componentChannels

Array of Channel

readonly

The color component channels for this document.

countItems

CountItems CountItem

readonly

The current count items in the document.

fullName

File

readonly

The full path name of the document.

guides

Guides Guide

readonly

The guides in this document.

height

UnitValue

readonly

The height of the document.

histogram

Array of Int

readonly

A histogram showing the number of pixels at each color intensity level for the composite channel.

Valid only when 'mode' = RGB, CMYK, or indexed.

historyStates

HistoryStates HistoryState

readonly

The history states collection in this document.

id

Int

readonly

The unique ID of this document.

info

DocumentInfo

readonly

Metadata about the document.

layerComps

LayerComps LayerComp

readonly

The layer comps collection in this document.

layerSets

LayerSets LayerSet

readonly

The layer sets collection in the document.

layers

Layers Layer

readonly

The layers collection in the document.

managed

Boolean

readonly

If true, the document is a workgroup document.

measurementScale

MeasurementScale

readonly

The measurement scale of the document.

mode

DocumentMode

DocumentMode.GRAYSCALE

DocumentMode.RGB

DocumentMode.CMYK

DocumentMode.LAB

DocumentMode.BITMAP

DocumentMode.INDEXEDCOLOR

DocumentMode.MULTICHANNEL

DocumentMode.DUOTONE

readonly

The color profile.

name

String

readonly

The document name.

parent

 

readonly

The object's container.

path

File

readonly

The path to the document.

pathItems

PathItems PathItem

readonly

The path items collection in this document.

pixelAspectRatio

Number

read/write

The (custom) pixel aspect ratio of the document. Range: 0.100 to 10.000.

printSettings

DocumentPrintSettings

readonly

Document print settings.

quickMaskMode

Boolean

read/write

If true, the document is in Quick Mask mode.

resolution

Number

readonly

The resolution of the document (in pixels per inch)

saved

Boolean

readonly

If true, the document been saved since the last change.

selection

Selection

readonly

The selected area of the document.

typename

String

readonly

The class name of the object.

width

UnitValue

readonly

The width of the document.

xmpMetadata

XMPMetadata

readonly

The XMP properties of the document. The Camera RAW settings are stored here.

Method Listing

undefined autoCount (channel:Channel, threshold:Int)

Counts the objects in the document.

Parameter

Type

Description

channel

Channel

The channel to use for counting.

threshold

Int (range 0 - 255)

Threshold to use for counting. Range: 0 to 255.

undefined changeMode (destinationMode:ChangeMode, [options:DocumentConversionOptions])

Changes the mode of the document.

Parameter

Type

Description

destinationMode

ChangeMode

ChangeMode.GRAYSCALE

ChangeMode.RGB

ChangeMode.CMYK

ChangeMode.LAB

ChangeMode.BITMAP

ChangeMode.INDEXEDCOLOR

ChangeMode.MULTICHANNEL

The mode to change to.

options

DocumentConversionOptions

Options for changing the mode.

undefined close ([saving:SaveOptionsType=SaveOptionsType])

Closes the document.

Parameter

Type

Description

saving

SaveOptionsType

SaveOptionsType.SAVECHANGES

SaveOptionsType.DONOTSAVECHANGES

SaveOptionsType.PROMPTTOSAVECHANGES

Specifies whether changes should be saved before closing.

(default: SaveOptionsType.PROMPTTOSAVECHANGES)

undefined convertProfile (destinationProfile:String, intent:Intent, [blackPointCompensation:Boolean], [dither:Boolean=Boolean])

Converts the document from using one color profile to using another.

Parameter

Type

Description

destinationProfile

String

The color profile to convert to. Either a string specifying a color profile, one of the working color spaces, or Lab color.

intent

Intent

Intent.PERCEPTUAL

Intent.SATURATION

Intent.RELATIVECOLORIMETRIC

Intent.ABSOLUTECOLORIMETRIC

The conversion intent.

blackPointCompensation

Boolean

If true, black point compensation is used.

dither

Boolean

If true, dither is used.

(default: true)

undefined crop (bounds:UnitRect, [angle:Number=Number], [width:UnitValue], [height:UnitValue])

Crops the document.

Parameter

Type

Description

bounds

UnitRect

The area to crop.

angle

Number

The angle of cropping bounds.

(default: 0)

width

UnitValue

The width of the resulting document.

height

UnitValue

The height of the resulting document.

Document duplicate (relativeObject:Object, insertionLocation:ElementPlacement)

Duplicate this object.

Parameter

Type

Description

relativeObject

Object

 

insertionLocation

ElementPlacement

ElementPlacement.PLACEAFTER

ElementPlacement.PLACEBEFORE

ElementPlacement.PLACEATEND

 

Document duplicate ([name:String], [mergeLayersOnly:Boolean])

Creates a duplicate of the document object.

Parameter

Type

Description

name

String

The name of the new document.

mergeLayersOnly

Boolean

If ture, duplicates merged layers only.

undefined exportDocument (exportIn:File, [exportAs:ExportType=ExportType], [options:ExportOptions])

Exports the document.

Parameter

Type

Description

exportIn

File

The file to export to.

exportAs

ExportType

ExportType.ILLUSTRATORPATHS

ExportType.SAVEFORWEB

The type of export.

(default: ExportType.ILLUSTRATORPATHS)

options

ExportOptions

Options for the specified export type.

undefined flatten ()

Flattens all layers.

undefined flipCanvas (direction:Direction)

Flips the canvas horizontally or vertically.

Parameter

Type

Description

direction

Direction

Direction.HORIZONTAL

Direction.VERTICAL

The direction in which to flip the canvas.

undefined importAnnotations (file:File)

Imports annotations into the document.

Parameter

Type

Description

file

File

The document to import annotations from.

undefined mergeVisibleLayers ()

Flattens all visible layers in the document.

ArtLayer paste ([intoSelection:Boolean=Boolean])

Pastes contents of the clipboard into the document.

Parameter

Type

Description

intoSelection

Boolean

If true, contents are pasted into the current selection.

(default: false)

undefined print ([sourceSpace:SourceSpaceType=SourceSpaceType], [printSpace:String], [intent:Intent=Intent], [blackPointCompensation:Boolean=Boolean])

Prints the document.

Parameter

Type

Description

sourceSpace

SourceSpaceType

SourceSpaceType.DOCUMENT

SourceSpaceType.PROOF

The color space for the source.

(default: SourceSpaceType.DOCUMENT)

printSpace

String

The color space for the printer. Can be "nothing" (meaning same as source); one of the working spaces or Lab color; or a string specifying a color space. Default: nothing.

intent

Intent

Intent.PERCEPTUAL

Intent.SATURATION

Intent.RELATIVECOLORIMETRIC

Intent.ABSOLUTECOLORIMETRIC

The color conversion intent.

(default: Intent.RELATIVECOLORIMETRIC)

blackPointCompensation

Boolean

If true, black point compensation is used.

(default: true)

undefined printOneCopy ()

Print one copy of the document.

undefined rasterizeAllLayers ()

Rasterizes all layers.

undefined recordMeasurements ([source:MeasurementSource], [dataPoints:Array of String])

Records the measurements of document.

Parameter

Type

Description

source

MeasurementSource

MeasurementSource.MEASURESELECTION

MeasurementSource.MEASURECOUNTTOOL

MeasurementSource.MEASURERULERTOOL

The source of the measurements to record.

dataPoints

Array of String

An array of identifiers of data points to record. Any data points not appropriate for the specified source are ignored.

undefined resizeCanvas ([width:UnitValue], [height:UnitValue], [anchor:AnchorPosition=AnchorPosition])

Changes the size of the canvas.

Parameter

Type

Description

width

UnitValue

The desired width of the canvas.

height

UnitValue

The desired height of the canvas.

anchor

AnchorPosition

AnchorPosition.TOPLEFT

AnchorPosition.TOPCENTER

AnchorPosition.TOPRIGHT

AnchorPosition.MIDDLELEFT

AnchorPosition.MIDDLECENTER

AnchorPosition.MIDDLERIGHT

AnchorPosition.BOTTOMLEFT

AnchorPosition.BOTTOMCENTER

AnchorPosition.BOTTOMRIGHT

The anchor point to resize around.

(default: AnchorPosition.MIDDLECENTER)

undefined resizeImage ([width:UnitValue], [height:UnitValue], [resolution:Number], [resampleMethod:ResampleMethod=ResampleMethod], [amount:Int=Int])

Changes the size of the image.

Parameter

Type

Description

width

UnitValue

The desired width of the image.

height

UnitValue

The desired height of the image.

resolution

Number

The resolution (in pixels per inch)

resampleMethod

ResampleMethod

ResampleMethod.NONE

ResampleMethod.NEARESTNEIGHBOR

ResampleMethod.BILINEAR

ResampleMethod.BICUBIC

ResampleMethod.BICUBICSHARPER

ResampleMethod.BICUBICSMOOTHER

ResampleMethod.BICUBICAUTOMATIC

ResampleMethod.AUTOMATIC

ResampleMethod.PRESERVEDETAILS

The downsample method.

(default: ResampleMethod.BICUBIC)

amount

Int (range 0 - 100)

Amount of noise value when using preserve details (range: 0 - 100)

(default: 0)

undefined revealAll ()

Expands the document to show clipped sections.

undefined rotateCanvas (angle:Number)

Rotates the canvas.

Parameter

Type

Description

angle

Number

The number of degrees to rotate. A positive angle rotates the canvas clockwise; a negative value rotates the canvas counter-clockwise.

undefined save ()

Saves the document.

undefined saveAs (saveIn:File, [options:Varies], [asCopy:Boolean], [extensionType:MacExtensionType])

Saves the document with the specified save options.

Parameter

Type

Description

saveIn

File

The file to save to, specified as a string containing the full file path or an alias. If not specified, the document is saved to its existing file.

options

Varies

Options for the specified file type.

asCopy

Boolean

Saves the document as a copy, leaving the original open.

extensionType

MacExtensionType

MacExtensionType.NONE

MacExtensionType.LOWERCASE

MacExtensionType.UPPERCASE

Appends the specified extension to the file name.

Document splitChannels ()

Splits the channels of the document.

undefined suspendHistory (historyString:String, javaScriptString:String)

Provides a single history state for the entire script. Allows a single undo for all actions taken in the script.

Parameter

Type

Description

historyString

String

The string to use for the history state.

javaScriptString

String

A string of JavaScript code to execute during the suspension of history.

undefined trap (width:Int)

Applies trapping to a CMYK document. Valid only when 'mode' = CMYK.

Parameter

Type

Description

width

Int

The trap width in pixels.

undefined trim ([type:TrimType=TrimType], [top:Boolean=Boolean], [left:Boolean=Boolean], [bottom:Boolean=Boolean], [right:Boolean=Boolean])

Trims the transparent area around the image on the specified sides of the canvas.

Parameter

Type

Description

type

TrimType

TrimType.TRANSPARENT

TrimType.TOPLEFT

TrimType.BOTTOMRIGHT

The color or type of pixels to base the trim on.

(default: TrimType.TOPLEFT)

top

Boolean

If true, trims away the top of the document.

(default: true)

left

Boolean

If true, trims away the left of the document.

(default: true)

bottom

Boolean

If true, trims away the bottom of the document.

(default: true)

right

Boolean

If true, trims away the right of the document.

(default: true)

Object of

Application.activeDocument

Return

Documents.add()

Document.duplicate()

Document.duplicate()

Documents.[]()

Documents.getByName()

Application.open()

Document.splitChannels()