newTextDocument(docText)
app.project.item(index).layer(index).property(SourceText").value
Description
The TextDocumentobject stores a value for a TextLayer’s Source Text property. Create it withthe constructor, passing the string to be encapsulated.
Examples
This sets a value of some source text and displays an alert showing the new value:
var myTextDocument = new TextDocument("Happy Cake");
myTextLayer.property("Source Text").setValue(myTextDocument);
alert(myTextLayer.property("Source Text").value);
This sets keyframe values for text that show different words over time:
var textProp = myTextLayer.property("Source Text");
textProp.setValueAtTime(0, new TextDocument("Happy"));
textProp.setValueAtTime(.33, new TextDocument("cake"));
textProp.setValueAtTime(.66, new TextDocument("is"));
textProp.setValueAtTime(1, new TextDocument("yummy!"));
This sets various character and paragraph settings for some text:
var textProp = myTextLayer.property("Source Text");
var textDocument = textProp.value;
myString = "Happy holidays!";
textDocument.resetCharStyle();
textDocument.fontSize = 60;
textDocument.fillColor = [1, 0, 0];
textDocument.strokeColor = [0, 1, 0];
textDocument.strokeWidth = 2;
textDocument.font = "TimesNewRomanPSMT";
textDocument.strokeOverFill = true;
textDocument.applyStroke = true;
textDocument.applyFill = true;
textDocument.text = myString;
textDocument.justification = ParagraphJustification.CENTER_JUSTIFY;
textDocument.tracking = 50;
textProp.setValue(textDocument);
Attributes
Attribute Reference Description
text “TextDocument text attribute” The text layer’s Source Text value.
font “TextDocument font attribute” The text layer’s font specified by its PostScript name.
fontSize “TextDocument fontSize attribute” The text layer’s font size in pixels.
applyFill “TextDocument applyFill attribute” When true, the text layer shows a fill.
Attribute Reference Description
applyStroke “TextDocument applyStroke attribute” When true, the text layer shows a stroke.
fillColor “TextDocument fillColor attribute” The text layer’s fill color.
strokeColor “TextDocument strokeColor attribute” The text layer’s stroke color.
strokeOverFi l l “TextDocument strokeOverFill attribute” Indicates the rendering order for the fill and stroke of a text layer.
strokeWidth “TextDocument strokeWidth attribute” The text layer’s stroke thickness.
justification “TextDocument justification attribute” The paragraph justification for the text layer.
tracking “TextDocument tracking attribute” The text layer’s spacing between characters.
pointText “TextDocument pointText attribute” When true, the text layer is point (unbounded) text.
boxText “TextDocument boxText attribute” When true, the text layer is paragraph (bounded) text.
boxTextSize “TextDocument boxTextSize attribute” For box text, the pixel dimensions for the text bounds.
Methods
Method Reference Description
resetCharStyle() “TextDocument resetCharStyle() method” Restores the default character settings in the Character panel.
resetParagraphStyle( ) “TextDocument resetParagraphStyle() method” Restores the default paragraph settings in the Paragraph panel.