TextItem
The Class that groups all Type related properties of a Text Layer in Photoshop.
const app = require('photoshop').app;
const textItem = app.activeDocument.activeLayers[0].textItem;
Some properties and methods are available directly in the TextItem instance itself:
textItem.contents; // "Lorem Ipsum"
textItem.contents = "Hello World";
textItem.isPointText; // true
await textItem.convertToParagraphText();
Most properties and methods are grouped for convenience in the characterStyle and paragraphStyle properties of TextItem.
textItem.characterStyle.size; // 12
textItem.characterStyle.size = 24;
textItem.paragraphStyle.hyphenation; // true
Finally, the warpStyle object contains all the properties related to the Warp effect applied to the text layer.
textItem.warpStyle.style; // "arcLower"
Please note that for some properties that are expressed in pixels, the valid range of values might depend on the document's resolution. When this is the case, you'll find that in the documentation "for a 72ppi document" is specified.
An example is the font size:
// Range: 0.01..1296—for a 72ppi document
textItem.characterStyle.size = 1000;
If you want to find the range for documents with a different resolution, please use the following conversion formula:
newVal = (documentResolution / 72) * referenceVal;
// I.e., for a 300ppi document the maximum font size will be:
// (300 / 72) * 1296 = 5400px
Upon setting a value, validation will be performed internally. An invalid value will result in a Range Error.
Properties
characterStyle
• characterStyle: CharacterStyle
The object that stores properties related to the Character panel in the Photoshop UI.
paragraphStyle
• paragraphStyle: ParagraphStyle
The object that stores properties related to the Paragraph panel in the Photoshop UI.
warpStyle
• warpStyle: WarpStyle
The object that stores properties related to the Warp Text dialog.
Properties
Methods
convertToParagraphText
<span class="minversion" style="display: block; margin-bottom: -1em; margin-left: 36em; float:left; opacity:0.5;">24.1</span>
<br/> Promise<TextItem>
Convert a Text Layer from Point Text to Paragraph Text
convertToPointText
<span class="minversion" style="display: block; margin-bottom: -1em; margin-left: 36em; float:left; opacity:0.5;">24.1</span>
<br/> Promise<TextItem>
Convert a Text Layer from Paragraph Text to Point Text
convertToShape
<span class="minversion" style="display: block; margin-bottom: -1em; margin-left: 36em; float:left; opacity:0.5;">24.1</span>
<br/> Promise<void>
Convert the Text Layer into a Shape Layer
createWorkPath
<span class="minversion" style="display: block; margin-bottom: -1em; margin-left: 36em; float:left; opacity:0.5;">24.1</span>
<br/> Promise<void>
Create a Work Path from the Text Layer