Skip to content

Paragraphs

app.activeDocument.textFrames[index].paragraphs

A collection of TextRange objects, with each TextRange representing a paragraph.

The elements are not named; you must access them by index.


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

The number of objects in the collection.

Number; read-only.


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

The parent of this object.

Object; read-only.


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

The class name of the referenced object.

String; read-only.


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

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.

ParameterTypeDescription
contentsStringText contents to add
relativeObjectTextFrameItem, optionalObject to add item to
insertionLocationElementPlacement, optionalLocation to place text

TextRange


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

Adds a new paragraph with specified text contents before the current text selection or insertion point.

ParameterTypeDescription
contentsStringText contents to add

TextRange


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

Gets an element from the collection.

ParameterTypeDescription
itemKeyString, NumberString or number key

TextRange


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

Deletes all elements in this collection.

Nothing.


// Counts all paragraphs in current doc and stores result in 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;
}
}