Paragraphs
Paragraphs
Section titled “Paragraphs”app.activeDocument.textFrames[index].paragraphs
Description
Section titled “Description”A collection of TextRange objects, with each TextRange
representing a paragraph.
The elements are not named; you must access them by index.
Properties
Section titled “Properties”Paragraphs.length
Section titled “Paragraphs.length”app.activeDocument.textFrames[index].paragraphs.length
Description
Section titled “Description”The number of objects in the collection.
Number; read-only.
Paragraphs.parent
Section titled “Paragraphs.parent”app.activeDocument.textFrames[index].paragraphs.parent
Description
Section titled “Description”The parent of this object.
Object; read-only.
Paragraphs.typename
Section titled “Paragraphs.typename”app.activeDocument.textFrames[index].paragraphs.typename
Description
Section titled “Description”The class name of the referenced object.
String; read-only.
Methods
Section titled “Methods”Paragraphs.add()
Section titled “Paragraphs.add()”app.activeDocument.textFrames[index].paragraphs.add(contents [,relativeObject] [,insertionLocation])
Description
Section titled “Description”Adds a new paragraph with specified text contents at the specified location in the current document. If location is not specified, adds the new paragraph to the containing text frame after the current text selection or insertion point.
Parameters
Section titled “Parameters”Parameter | Type | Description |
---|---|---|
contents | String | Text contents to add |
relativeObject | TextFrameItem, optional | Object to add item to |
insertionLocation | ElementPlacement, optional | Location to place text |
Returns
Section titled “Returns”Paragraphs.addBefore()
Section titled “Paragraphs.addBefore()”app.activeDocument.textFrames[index].paragraphs.addBefore(contents)
Description
Section titled “Description”Adds a new paragraph with specified text contents before the current text selection or insertion point.
Parameters
Section titled “Parameters”Parameter | Type | Description |
---|---|---|
contents | String | Text contents to add |
Returns
Section titled “Returns”Paragraphs.index()
Section titled “Paragraphs.index()”app.activeDocument.textFrames[index].paragraphs.index(itemKey)
Description
Section titled “Description”Gets an element from the collection.
Parameters
Section titled “Parameters”Parameter | Type | Description |
---|---|---|
itemKey | String, Number | String or number key |
Returns
Section titled “Returns”Paragraphs.removeAll()
Section titled “Paragraphs.removeAll()”app.activeDocument.textFrames[index].paragraphs.removeAll()
Description
Section titled “Description”Deletes all elements in this collection.
Returns
Section titled “Returns”Nothing.
Example
Section titled “Example”Counting paragraphs
Section titled “Counting paragraphs”// Counts all paragraphs in current doc and stores result in paragraphCountif (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; }}