Adobe Photoshop CS5 Object Library JS: Document
From Photoshop CS5
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, trimHierarchy
Properties
| Property | Type | Access | Description |
|---|---|---|---|
| ColorProfile | ColorProfile: ColorProfile.NONE ColorProfile.WORKING ColorProfile.CUSTOM |
r/w | The type of color model that defines the working space of the document. |
| activeChannels | Array of Channel | r/w | The selected channels. |
| activeHistoryBrushSource | HistoryState | r/w | The history state to use with the history brush. |
| activeHistoryState | HistoryState | r/w | The current history state for this document. |
| activeLayer | Layer | r/w | 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 |
r/w | The number of bits per channel. |
| channels | Channels Channel | readonly | The channels collection in this document. |
| colorProfileName | string | r/w | The name of the color profile. Valid only when no value is specified for color profile kind (to indicate a custom color profile). |
| 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. |
| 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. |
| 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 | bool | 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 | Object | 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 | r/w | The (custom) pixel aspect ratio of the document. Range: 0.100 to 10.000. |
| printSettings | DocumentPrintSettings | readonly | Document print settings. |
| quickMaskMode | bool | r/w | If true, the document is in Quick Mask mode. |
| resolution | number | readonly | The resolution of the document (in pixels per inch) |
| saved | bool | 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. |
Methods
Instances
void 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. |
void 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. (Optional) |
void close ([saving:
SaveOptions=SaveOptions.PROMPTTOSAVECHANGES])
Closes the document.
| Parameter | Type | Description |
|---|---|---|
| saving | SaveOptions: 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.
| 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 | bool | If true, black point compensation is used. (Optional) |
| dither | bool | If true, dither is used. (default: true) (Optional) |
void crop (bounds:
UnitRect[, angle:
number=0][, 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) (Optional) |
| width | UnitValue | The width of the resulting document. (Optional) |
| height | UnitValue | The height of the resulting document. (Optional) |
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:
bool])
Creates a duplicate of the document object.
| Parameter | Type | Description |
|---|---|---|
| name | string | The name of the new document. (Optional) |
| mergeLayersOnly | bool | If ture, duplicates merged layers only. (Optional) |
void exportDocument (exportIn:
File[, exportAs:
ExportType=ExportType.ILLUSTRATORPATHS][, 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) (Optional) |
| options | ExportOptions | Options for the specified export type. (Optional) |
void flatten ()
Flattens all layers.
void 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. |
void importAnnotations (file:
File)
Imports annotations into the document.
| Parameter | Type | Description |
|---|---|---|
| file | File | The 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.
| Parameter | Type | Description |
|---|---|---|
| intoSelection | bool | If 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.
| Parameter | Type | Description |
|---|---|---|
| postScriptEncoding | PrintEncoding: PrintEncoding.BINARY PrintEncoding.JPEG PrintEncoding.ASCII | The encoding type. (default: PrintEncoding.BINARY) (Optional) |
| sourceSpace | SourceSpaceType: SourceSpaceType.DOCUMENT SourceSpaceType.PROOF | The color space for the source. (default: SourceSpaceType.DOCUMENT) (Optional) |
| 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. (Optional) |
| intent | Intent: Intent.PERCEPTUAL Intent.SATURATION Intent.RELATIVECOLORIMETRIC Intent.ABSOLUTECOLORIMETRIC | The color conversion intent. (default: Intent.RELATIVECOLORIMETRIC) (Optional) |
| blackPointCompensation | bool | If 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.
| Parameter | Type | Description |
|---|---|---|
| source | MeasurementSource: MeasurementSource.MEASURESELECTION MeasurementSource.MEASURECOUNTTOOL MeasurementSource.MEASURERULERTOOL | The source of the measurements to record. (Optional) |
| dataPoints | Array of string | An 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.
| Parameter | Type | Description |
|---|---|---|
| width | UnitValue | The desired width of the canvas. (Optional) |
| height | UnitValue | The desired height of the canvas. (Optional) |
| 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) (Optional) |
void resizeImage ([width:
UnitValue][, height:
UnitValue][, resolution:
number][, resampleMethod:
ResampleMethod=ResampleMethod.BICUBIC])
Changes the size of the image.
| Parameter | Type | Description |
|---|---|---|
| width | UnitValue | The desired width of the image. (Optional) |
| height | UnitValue | The desired height of the image. (Optional) |
| resolution | number | The resolution (in pixels per inch) (Optional) |
| resampleMethod | ResampleMethod: 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.
| 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. |
void save ()
Saves the document.
void saveAs (saveIn:
File[, options:
any][, asCopy:
bool][, extensionType:
Extension])
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 | any | Options for the specified file type. (Optional) |
| asCopy | bool | Saves the document as a copy, leaving the original open. (Optional) |
| extensionType | Extension: 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.
| 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. |
void trap (width:
int)
Applies trapping to a CMYK document. Valid only when 'mode' = CMYK.
| Parameter | Type | Description |
|---|---|---|
| width | int | The 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.
| 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) (Optional) |
| top | bool | If true, trims away the top of the document. (default: true) (Optional) |
| left | bool | If true, trims away the left of the document. (default: true) (Optional) |
| bottom | bool | If true, trims away the bottom of the document. (default: true) (Optional) |
| right | bool | If 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.3i | Contents :: Index |