Skip to content

Characters

app.activeDocument.textFrames[index].contents

A collection of characters (TextRange objects of length 1).

The elements are not named; you must access them by index.


app.activeDocument.textFrames[index].contents.length

The number of characters in the collection.

Number; read-only.


app.activeDocument.textFrames[index].contents.parent

The text art item that contains this character.

Object; read-only.


app.activeDocument.textFrames[index].contents.typename

The class name of the referenced object.

String; read-only.


app.activeDocument.textFrames[index].contents.add(contents[,relativeObject][,insertionLocation])

Adds a new character with specified text contents at the specified location in the current document.

If a location is not specified, adds the new character to the containing text frame after the current text selection or insertion point.

ParameterTypeDescription
contentsStringText contents to add
relativeObjectTextFrameItem, optionalObject to add item to
insertionLocationElementPlacement, optionalLocation to place text

TextRange


app.activeDocument.textFrames[index].contents.addBefore(contents)

Adds a character before the specified text selection.

ParameterTypeDescription
contentsStringText contents to add

TextRange


app.activeDocument.textFrames[index].contents.index(itemKey)

Gets an element from the collection.

ParameterTypeDescription
itemKeyString, NumberString or number key

TextRange


app.activeDocument.textFrames[index].contents.removeAll()

Deletes all elements in the collection.

Nothing.


// Counts all characters in the active document,
// including whitespace, and stores in numChars
if (app.documents.length > 0) {
var doc = app.activeDocument;
var numChars = 0;
for (var i = 0; i < doc.textFrames.length; i++) {
var textArtRange = doc.textFrames[i].contents;
numChars += textArtRange.length;
}
}