GraphicStyle
GraphicStyle
Section titled “GraphicStyle”app.activeDocument.graphicStyles[index]
Description
Section titled “Description”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.
Properties
Section titled “Properties”GraphicStyle.name
Section titled “GraphicStyle.name”app.activeDocument.graphicStyles[index].name
Description
Section titled “Description”The graphic style name.
String.
GraphicStyle.parent
Section titled “GraphicStyle.parent”app.activeDocument.graphicStyles[index].parent
Description
Section titled “Description”The document that contains this graphic style.
Document; read-only.
GraphicStyle.typename
Section titled “GraphicStyle.typename”app.activeDocument.graphicStyles[index].typename
Description
Section titled “Description”The class name of the referenced object.
String; read-only.
Methods
Section titled “Methods”GraphicStyle.applyTo()
Section titled “GraphicStyle.applyTo()”app.activeDocument.graphicStyles[index].applyTo(artItem)
Description
Section titled “Description”Applies this art style to a specified art item.
Parameters
Section titled “Parameters”Parameter | Type | Description |
---|---|---|
artItem | PageItem | Target art item |
Returns
Section titled “Returns”Nothing.
GraphicStyle.mergeTo()
Section titled “GraphicStyle.mergeTo()”app.activeDocument.graphicStyles[index].mergeTo(artItem)
Description
Section titled “Description”Merges this art style into the current styles of a specified art item.
Parameters
Section titled “Parameters”Parameter | Type | Description |
---|---|---|
artItem | PageItem | Target art item |
Returns
Section titled “Returns”Nothing.
GraphicStyle.remove()
Section titled “GraphicStyle.remove()”app.activeDocument.graphicStyles[index].remove()
Description
Section titled “Description”Deletes this object.
Returns
Section titled “Returns”Nothing.
Example
Section titled “Example”Applying a graphic style
Section titled “Applying a graphic style”// 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]); }}