Skip to content

ParagraphStyles

app.activeDocument.paragraphStyles

A collection of ParagraphStyle objects.


app.activeDocument.paragraphStyles.length

Number of elements in the collection.

Number; read-only.


app.activeDocument.paragraphStyles.parent

The object’s container.

Object; read-only.


app.activeDocument.paragraphStyles.typename

The class name of the object.

String; read-only.


app.activeDocument.paragraphStyles.add(name)

Creates a named paragraph style.

ParameterTypeDescription
nameStringName of element to get

ParagraphStyle


app.activeDocument.paragraphStyles.getByName(name)

Get the first element in the collection with the provided name.

ParameterTypeDescription
nameStringName of element to get

ParagraphStyle


app.activeDocument.paragraphStyles.index(itemKey)

Gets an element from the collection.

ParameterTypeDescription
itemKeyString, NumberString or number key

ParagraphStyle


app.activeDocument.paragraphStyles.removeAll()

Deletes all elements in the collection.

Nothing.


// Creates a new document with 1 text frame and 3 paragraphs
// gives each paragraph a different justification, then creates
// a paragraph style and applies it to all paragraphs
var docRef = documents.add();
var pathRef = docRef.pathItems.rectangle(600, 200, 200, 400);
var textRef = docRef.textFrames.areaText(pathRef);
textRef.paragraphs.add("Left justified paragraph.");
textRef.paragraphs.add("Center justified paragraph.");
textRef.paragraphs.add("Right justified paragraph.");
textRef.textRange.characterAttributes.size = 28;
// change the justification of each paragraph
// using the paragraph attributes object
var paraAttr_0 = textRef.paragraphs[0].paragraphAttributes;
paraAttr_0.justification = Justification.RIGHT;
var paraAttr_1 = textRef.paragraphs[1].paragraphAttributes;
paraAttr_1.justification = Justification.CENTER;
var paraAttr_2 = textRef.paragraphs[2].paragraphAttributes;
paraAttr_2.justification = Justification.LEFT;
// create a new paragraph style
var paraStyle = docRef.paragraphStyles.add("LeftIndent");
// add some paragraph attributes
var paraAttr = paraStyle.paragraphAttributes;
paraAttr.justification = Justification.LEFT;
paraAttr.firstLineIndent = 10;
// apply the style to each item in the document
var iCount = textRef.paragraphs.length;
for (var i = 0; i < iCount; i++) {
paraStyle.applyTo(textRef.paragraphs[i], true);
}
redraw();