Skip to content

Tags

app.activeDocument.selection[index].tags

A collection of Tag objects.


app.activeDocument.selection[index].tags.length

The number of elements in the collection.

Number; read-only.


app.activeDocument.selection[index].tags.parent

The object’s container.

Object; read-only.


app.activeDocument.selection[index].tags.typename

The class name of the referenced object.

String; read-only.


app.activeDocument.selection[index].tags.add()

Creates a new Tag object.

Tag


app.activeDocument.selection[index].tags.getByName(name)

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

ParameterTypeDescription
nameStringName of element to get

Tag


app.activeDocument.selection[index].tags.index(itemKey)

Gets an element from the collection.

ParameterTypeDescription
itemKeyString, NumberString or number key

Tag


app.activeDocument.selection[index].tags.removeAll()

Deletes all elements in this collection.

Nothing.


// Adds tags to all RasterItems and PlacedItems in the current document
if ( app.documents.length > 0 ) {
var doc = app.activeDocument;
if ( doc.placedItems.length + doc.rasterItems.length > 0 ) {
for ( i = 0; i < doc.pageItems.length; i++ ) {
var imageArt = doc.pageItems[i];
if ( imageArt.typename == "PlacedItem" || imageArt.typename == "RasterItem") {
// Create a new Tag with the name AdobeURL and the
// value of the www link
var urlTAG = imageArt.tags.add();
urlTAG.name = "AdobeWebSite";
urlTAG.value = "http://www.adobe.com/";
}
}
} else {
alert( "No placed or raster items in the document" );
}
}