Skip to content

GraphicStyle

app.activeDocument.graphicStyles[index]

A graphic style. Each graphic style defines a set of appearance attributes that you can apply non-destructively to page items. Graphic styles are contained in documents. Scripts cannot create new graphic styles.


app.activeDocument.graphicStyles[index].name

The graphic style name.

String.


app.activeDocument.graphicStyles[index].parent

The document that contains this graphic style.

Document; read-only.


app.activeDocument.graphicStyles[index].typename

The class name of the referenced object.

String; read-only.


app.activeDocument.graphicStyles[index].applyTo(artItem)

Applies this art style to a specified art item.

ParameterTypeDescription
artItemPageItemTarget art item

Nothing.


app.activeDocument.graphicStyles[index].mergeTo(artItem)

Merges this art style into the current styles of a specified art item.

ParameterTypeDescription
artItemPageItemTarget art item

Nothing.


app.activeDocument.graphicStyles[index].remove()

Deletes this object.

Nothing.


// Duplicates each path item in the selection, places the duplicate into a new group,
// then applies a graphic style to the new groups items
if (app.documents.length > 0) {
var doc = app.activeDocument;
var selected = doc.selection;
var newGroup = doc.groupItems.add();
newGroup.name = "NewGroup";
newGroup.move(doc, ElementPlacement.PLACEATEND);
var endIndex = selected.length;
for (var i = 0; i < endIndex; i++) {
if (selected[i].typename == "PathItem")
selected[i].duplicate(newGroup, ElementPlacement.PLACEATEND);
}
for (i = 0; i < newGroup.pageItems.length; i++) {
doc.graphicStyles[1].applyTo(newGroup.pageItems[i]);
}
}