Photoshop CS Scripting Guide
79
Scripting Photoshop
Text item object
3
JS:
docRef.artLayers["my text"].textItem.justification =
Justification.RIGHT;
I M P O R T A N T :
The
text item
object has a
kind
property, which can be set to either
point
text (psPointText/TextType.POINTTEXT
) or
paragraph text
(psParagraphText/TextType.PARAGRAPHTEXT
). When a new
text
item
is created, its
kind
property is automatically set to
point text
.
The
text item
properties
height, width
and
leading
are only valid
when the text item's kind property is set to
paragraph text.
3.11.1 Setting the contents of the text item
To set the contents of a text item in AppleScript you would write:
set contents of text object of art layer "Layer 1" of ¬
current document to "Hello"
If you use a text item object reference to set the contents you will need to write:
set contents of contents of textItemRef to "Hello"
The second “contents of” is needed because “contents” is a keyword which tells AppleScript
to operate on the contents of the variable, rather than on the object to which it may refer. This
means that AppleScript sees the above line as:
set text object of art layer 1 of document "Untitled-1" ¬
to "Hello"
To set the contents using references in VB and JS, write the following:
VB:
textLayerRef.TextItem.Contents = "Hello"
JS:
textLayerRef.textItem.contents = "Hello";