Tag
app.activeDocument.selection[index].tags[index]
Description
Section titled “Description”A label associated with a specific piece of artwork.
Tags allows you to assign an unlimited number of key-value pairs to any page item in a document.
Properties
Section titled “Properties”Tag.name
Section titled “Tag.name”app.activeDocument.selection[index].tags[index].name
Description
Section titled “Description”The tag’s name.
String; read-only.
Tag.parent
Section titled “Tag.parent”app.activeDocument.selection[index].tags[index].parent
Description
Section titled “Description”The object that contains this tag.
Object; read-only.
Tag.typename
Section titled “Tag.typename”app.activeDocument.selection[index].tags[index].typename
Description
Section titled “Description”The class name of the object.
String; read-only.
Tag.value
Section titled “Tag.value”app.activeDocument.selection[index].tags[index].value
Description
Section titled “Description”The data stored in this tag.
String; read-only.
Methods
Section titled “Methods”Tag.remove()
Section titled “Tag.remove()”app.activeDocument.selection[index].tags[index].remove()
Description
Section titled “Description”Deletes this object.
Returns
Section titled “Returns”Nothing.
Example
Section titled “Example”Using tags
Section titled “Using tags”// Finds the tags associated with the selected art item,// show names and values in a separate document
if ( app.documents.length > 0 ) { doc = app.activeDocument;
if ( doc.selection.length > 0 ) { for ( i = 0; i < selection.length; i++ ) { selectedArt = selection[0]; tagList = selectedArt.tags;
if (tagList.length == 0) { var tempTag = tagList.add(); tempTag.name = "OneWord"; tempTag.value = "anything you want"; }
// Create a document and add a line of text per tag reportDocument = app.documents.add(); top_offset = 400;
for ( i = 0; i < tagList.length; i++ ) { tagText = tagList[i].value; newItem = reportDocument.textFrames.add(); newItem.contents = "Tag: (" + tagList[i].name + " , " + tagText + ")"; newItem.position = Array(100, top_offset); newItem.textRange.size = 24; top_offset = top_offset - 20; } } }}