Adobe Photoshop CS5 Object Library JS: Document

Photoshop CS5

Class

Document

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

QuickLinks

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

Hierarchy

Object
Document

Properties

PropertyTypeAccessDescription
ColorProfileColorProfile:
ColorProfile.NONE
ColorProfile.WORKING
ColorProfile.CUSTOM
r/wThe type of color model that defines the working space of the document.
activeChannels Array of Channel r/wThe selected channels.
activeHistoryBrushSourceHistoryState r/wThe history state to use with the history brush.
activeHistoryStateHistoryState r/wThe current history state for this document.
activeLayerLayer r/wThe selected layer.
artLayersArtLayers ArtLayer readonlyThe art layers collection in the document.
backgroundLayerArtLayer readonlyThe background layer for the document.
bitsPerChannelBitsPerChannelType:
BitsPerChannelType.ONE
BitsPerChannelType.EIGHT
BitsPerChannelType.SIXTEEN
BitsPerChannelType.THIRTYTWO
r/wThe number of bits per channel.
channelsChannels Channel readonlyThe channels collection in this document.
colorProfileNamestring r/wThe name of the color profile. Valid only when no value is specified for color profile kind (to indicate a custom color profile).
colorSamplersColorSamplers ColorSampler readonlyThe current color samplers associated with the document.
componentChannels Array of Channel readonlyThe color component channels for this document.
countItemsCountItems CountItem readonlyThe current count items in the document.
fullNameFile readonlyThe full path name of the document.
heightUnitValue readonlyThe height of the document.
histogram Array of int readonlyA histogram showing the number of pixels at each color intensity level for the composite channel.
Valid only when 'mode' = RGB, CMYK, or indexed.
historyStatesHistoryStates HistoryState readonlyThe history states collection in this document.
infoDocumentInfo readonlyMetadata about the document.
layerCompsLayerComps LayerComp readonlyThe layer comps collection in this document.
layerSetsLayerSets LayerSet readonlyThe layer sets collection in the document.
layersLayers Layer readonlyThe layers collection in the document.
managedbool readonlyIf true, the document is a workgroup document.
measurementScaleMeasurementScale readonlyThe measurement scale of the document.
modeDocumentMode:
DocumentMode.GRAYSCALE
DocumentMode.RGB
DocumentMode.CMYK
DocumentMode.LAB
DocumentMode.BITMAP
DocumentMode.INDEXEDCOLOR
DocumentMode.MULTICHANNEL
DocumentMode.DUOTONE
readonlyThe color profile.
namestring readonlyThe document name.
parentObject readonlyThe object's container.
pathFile readonlyThe path to the document.
pathItemsPathItems PathItem readonlyThe path items collection in this document.
pixelAspectRationumber r/wThe (custom) pixel aspect ratio of the document. Range: 0.100 to 10.000.
printSettingsDocumentPrintSettings readonlyDocument print settings.
quickMaskModebool r/wIf true, the document is in Quick Mask mode.
resolutionnumber readonlyThe resolution of the document (in pixels per inch)
savedbool readonlyIf true, the document been saved since the last change.
selectionSelection readonlyThe selected area of the document.
typenamestring readonlyThe class name of the object.
widthUnitValue readonlyThe width of the document.
xmpMetadataXMPMetadata readonlyThe XMP properties of the document. The Camera RAW settings are stored here.

Methods

Instances

void autoCount (channel: Channel, threshold: int)
Counts the objects in the document.

ParameterTypeDescription
channelChannelThe channel to use for counting.
thresholdint (range: 0 - 255)Threshold to use for counting. Range: 0 to 255.

void changeMode (destinationMode: ChangeMode[, options: DocumentConversionOptions])
Changes the mode of the document.

ParameterTypeDescription
destinationModeChangeMode:
ChangeMode.GRAYSCALE
ChangeMode.RGB
ChangeMode.CMYK
ChangeMode.LAB
ChangeMode.BITMAP
ChangeMode.INDEXEDCOLOR
ChangeMode.MULTICHANNEL
The mode to change to.
optionsDocumentConversionOptionsOptions for changing the mode. (Optional)

void close ([saving: SaveOptions=SaveOptions.PROMPTTOSAVECHANGES])
Closes the document.

ParameterTypeDescription
savingSaveOptions:
SaveOptions.SAVECHANGES
SaveOptions.DONOTSAVECHANGES
SaveOptions.PROMPTTOSAVECHANGES
Specifies whether changes should be saved before closing. (default: SaveOptions.PROMPTTOSAVECHANGES) (Optional)

void convertProfile (destinationProfile: string, intent: Intent[, blackPointCompensation: bool][, dither: bool=true])
Converts the document from using one color profile to using another.

ParameterTypeDescription
destinationProfilestringThe color profile to convert to. Either a string specifying a color profile, one of the working color spaces, or Lab color.
intentIntent:
Intent.PERCEPTUAL
Intent.SATURATION
Intent.RELATIVECOLORIMETRIC
Intent.ABSOLUTECOLORIMETRIC
The conversion intent.
blackPointCompensationboolIf true, black point compensation is used. (Optional)
ditherboolIf true, dither is used. (default: true) (Optional)

void crop (bounds: UnitRect[, angle: number=0][, width: UnitValue][, height: UnitValue])
Crops the document.

ParameterTypeDescription
boundsUnitRectThe area to crop.
anglenumberThe angle of cropping bounds. (default: 0) (Optional)
widthUnitValueThe width of the resulting document. (Optional)
heightUnitValueThe height of the resulting document. (Optional)

Document duplicate (relativeObject: Object, insertionLocation: ElementPlacement)
Duplicate this object.

ParameterTypeDescription
relativeObjectObject
insertionLocationElementPlacement:
ElementPlacement.PLACEAFTER
ElementPlacement.PLACEBEFORE
ElementPlacement.PLACEATEND

Document duplicate ([name: string][, mergeLayersOnly: bool])
Creates a duplicate of the document object.

ParameterTypeDescription
namestringThe name of the new document. (Optional)
mergeLayersOnlyboolIf ture, duplicates merged layers only. (Optional)

void exportDocument (exportIn: File[, exportAs: ExportType=ExportType.ILLUSTRATORPATHS][, options: ExportOptions])
Exports the document.

ParameterTypeDescription
exportInFileThe file to export to.
exportAsExportType:
ExportType.ILLUSTRATORPATHS
ExportType.SAVEFORWEB
The type of export. (default: ExportType.ILLUSTRATORPATHS) (Optional)
optionsExportOptionsOptions for the specified export type. (Optional)

void flatten ()
Flattens all layers.

void flipCanvas (direction: Direction)
Flips the canvas horizontally or vertically.

ParameterTypeDescription
directionDirection:
Direction.HORIZONTAL
Direction.VERTICAL
The direction in which to flip the canvas.

void importAnnotations (file: File)
Imports annotations into the document.

ParameterTypeDescription
fileFileThe document to import annotations from.

void mergeVisibleLayers ()
Flattens all visible layers in the document.

ArtLayer paste ([intoSelection: bool=false])
Pastes contents of the clipboard into the document.

ParameterTypeDescription
intoSelectionboolIf true, contents are pasted into the current selection. (default: false) (Optional)

void print ([postScriptEncoding: PrintEncoding=PrintEncoding.BINARY][, sourceSpace: SourceSpaceType=SourceSpaceType.DOCUMENT][, printSpace: string][, intent: Intent=Intent.RELATIVECOLORIMETRIC][, blackPointCompensation: bool=true])
Prints the document.

ParameterTypeDescription
postScriptEncodingPrintEncoding:
PrintEncoding.BINARY
PrintEncoding.JPEG
PrintEncoding.ASCII
The encoding type. (default: PrintEncoding.BINARY) (Optional)
sourceSpaceSourceSpaceType:
SourceSpaceType.DOCUMENT
SourceSpaceType.PROOF
The color space for the source. (default: SourceSpaceType.DOCUMENT) (Optional)
printSpacestringThe 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. (Optional)
intentIntent:
Intent.PERCEPTUAL
Intent.SATURATION
Intent.RELATIVECOLORIMETRIC
Intent.ABSOLUTECOLORIMETRIC
The color conversion intent. (default: Intent.RELATIVECOLORIMETRIC) (Optional)
blackPointCompensationboolIf true, black point compensation is used. (default: true) (Optional)

void printOneCopy ()
Print one copy of the document.

void rasterizeAllLayers ()
Rasterizes all layers.

void recordMeasurements ([source: MeasurementSource][, dataPoints: Array of string])
Records the measurements of document.

ParameterTypeDescription
sourceMeasurementSource:
MeasurementSource.MEASURESELECTION
MeasurementSource.MEASURECOUNTTOOL
MeasurementSource.MEASURERULERTOOL
The source of the measurements to record. (Optional)
dataPoints Array of stringAn array of identifiers of data points to record. Any data points not appropriate for the specified source are ignored. (Optional)

void resizeCanvas ([width: UnitValue][, height: UnitValue][, anchor: AnchorPosition=AnchorPosition.MIDDLECENTER])
Changes the size of the canvas.

ParameterTypeDescription
widthUnitValueThe desired width of the canvas. (Optional)
heightUnitValueThe desired height of the canvas. (Optional)
anchorAnchorPosition:
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) (Optional)

void resizeImage ([width: UnitValue][, height: UnitValue][, resolution: number][, resampleMethod: ResampleMethod=ResampleMethod.BICUBIC])
Changes the size of the image.

ParameterTypeDescription
widthUnitValueThe desired width of the image. (Optional)
heightUnitValueThe desired height of the image. (Optional)
resolutionnumberThe resolution (in pixels per inch) (Optional)
resampleMethodResampleMethod:
ResampleMethod.NONE
ResampleMethod.NEARESTNEIGHBOR
ResampleMethod.BILINEAR
ResampleMethod.BICUBIC
ResampleMethod.BICUBICSHARPER
ResampleMethod.BICUBICSMOOTHER
The downsample method. (default: ResampleMethod.BICUBIC) (Optional)

void revealAll ()
Expands the document to show clipped sections.

void rotateCanvas (angle: number)
Rotates the canvas.

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

void save ()
Saves the document.

void saveAs (saveIn: File[, options: any][, asCopy: bool][, extensionType: Extension])
Saves the document with the specified save options.

ParameterTypeDescription
saveInFileThe 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 any Options for the specified file type. (Optional)
asCopyboolSaves the document as a copy, leaving the original open. (Optional)
extensionTypeExtension:
Extension.NONE
Extension.LOWERCASE
Extension.UPPERCASE
Appends the specified extension to the file name. (Optional)

Array of Document splitChannels ()
Splits the channels of the document.

void 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.

ParameterTypeDescription
historyStringstringThe string to use for the history state.
javaScriptStringstringA string of JavaScript code to execute during the suspension of history.

void trap (width: int)
Applies trapping to a CMYK document. Valid only when 'mode' = CMYK.

ParameterTypeDescription
widthintThe trap width in pixels.

void trim ([type: TrimType=TrimType.TOPLEFT][, top: bool=true][, left: bool=true][, bottom: bool=true][, right: bool=true])
Trims the transparent area around the image on the specified sides of the canvas.

ParameterTypeDescription
typeTrimType:
TrimType.TRANSPARENT
TrimType.TOPLEFT
TrimType.BOTTOMRIGHT
The color or type of pixels to base the trim on. (default: TrimType.TOPLEFT) (Optional)
topboolIf true, trims away the top of the document. (default: true) (Optional)
leftboolIf true, trims away the left of the document. (default: true) (Optional)
bottomboolIf true, trims away the bottom of the document. (default: true) (Optional)
rightboolIf true, trims away the right of the document. (default: true) (Optional)

Element of

Application.activeDocument

Used in:

Channel Channel.duplicate ([targetDocument: Document])

Return

Document Application.open (document: File[, as: any][, asSmartObject: bool=false])

Document Document.duplicate (relativeObject: Object, insertionLocation: ElementPlacement)

Document Document.duplicate ([name: string][, mergeLayersOnly: bool])

Array of Document Document.splitChannels ()

Document Documents.[] (index: uint)

Document Documents.add ([width: UnitValue][, height: UnitValue][, resolution: number=72][, name: string][, mode: NewDocumentMode=NewDocumentMode.RGB][, initialFill: DocumentFill=DocumentFill.WHITE][, pixelAspectRatio: number=1.0][, bitsPerChannel: BitsPerChannelType=BitsPerChannelType.EIGHT][, colorProfileName: string])

Document Documents.getByName (name: string)

Jongware, 28-Aug-2012 v3.0.3iContents :: Index