跳转到内容

字符

app.activeDocument.textFrames[index].contents

字符的集合(长度为1的TextRange对象)。

元素没有名称;必须通过索引访问它们。


app.activeDocument.textFrames[index].contents.length

集合中的字符数量。

数字;只读。


app.activeDocument.textFrames[index].contents.parent

包含此字符的文本艺术项。

对象;只读。


app.activeDocument.textFrames[index].contents.typename

引用对象的类名。

字符串;只读。


app.activeDocument.textFrames[index].contents.add(contents[,relativeObject][,insertionLocation])

在当前文档的指定位置添加具有指定文本内容的新字符。

如果未指定位置,则将新字符添加到包含文本框架中的当前文本选择或插入点之后。

参数类型描述
contents字符串要添加的文本内容
relativeObjectTextFrameItem, 可选要添加到的对象
insertionLocationElementPlacement, 可选放置文本的位置

TextRange


app.activeDocument.textFrames[index].contents.addBefore(contents)

在指定的文本选择之前添加一个字符。

参数类型描述
contents字符串要添加的文本内容

TextRange


app.activeDocument.textFrames[index].contents.index(itemKey)

从集合中获取一个元素。

参数类型描述
itemKey字符串, 数字字符串或数字键

TextRange


app.activeDocument.textFrames[index].contents.removeAll()

删除集合中的所有元素。

无。


// 统计活动文档中的所有字符数量,
// 包括空白字符,并存储在numChars中
if (app.documents.length > 0) {
var doc = app.activeDocument;
var numChars = 0;
for (var i = 0; i < doc.textFrames.length; i++) {
var textArtRange = doc.textFrames[i].contents;
numChars += textArtRange.length;
}
}