段落
app.activeDocument.textFrames[index].paragraphs
一个 TextRange 对象的集合,每个 TextRange 代表一个段落。
元素没有名称;必须通过索引访问它们。
Paragraphs.length
Section titled “Paragraphs.length”app.activeDocument.textFrames[index].paragraphs.length
集合中对象的数量。
数字;只读。
Paragraphs.parent
Section titled “Paragraphs.parent”app.activeDocument.textFrames[index].paragraphs.parent
此对象的父对象。
对象;只读。
Paragraphs.typename
Section titled “Paragraphs.typename”app.activeDocument.textFrames[index].paragraphs.typename
引用对象的类名。
字符串;只读。
Paragraphs.add()
Section titled “Paragraphs.add()”app.activeDocument.textFrames[index].paragraphs.add(contents [,relativeObject] [,insertionLocation])
在当前文档的指定位置添加具有指定文本内容的新段落。如果未指定位置,则将新段落添加到包含文本框架中当前文本选择或插入点之后。
| 参数 | 类型 | 描述 | 
|---|---|---|
| contents | 字符串 | 要添加的文本内容 | 
| relativeObject | TextFrameItem,可选 | 要添加到的对象 | 
| insertionLocation | ElementPlacement,可选 | 放置文本的位置 | 
Paragraphs.addBefore()
Section titled “Paragraphs.addBefore()”app.activeDocument.textFrames[index].paragraphs.addBefore(contents)
在当前文本选择或插入点之前添加具有指定文本内容的新段落。
| 参数 | 类型 | 描述 | 
|---|---|---|
| contents | 字符串 | 要添加的文本内容 | 
Paragraphs.index()
Section titled “Paragraphs.index()”app.activeDocument.textFrames[index].paragraphs.index(itemKey)
从集合中获取一个元素。
| 参数 | 类型 | 描述 | 
|---|---|---|
| itemKey | 字符串,数字 | 字符串或数字键 | 
Paragraphs.removeAll()
Section titled “Paragraphs.removeAll()”app.activeDocument.textFrames[index].paragraphs.removeAll()
删除此集合中的所有元素。
无。
// 计算当前文档中的所有段落并将结果存储在 paragraphCount 中if (app.documents.length > 0) { var doc = app.activeDocument; var paragraphCount = 0; for (var i = 0; i < doc.textFrames.length; i++) { paragraphCount += doc.textFrames[i].paragraphs.length; }}