Skip to content

TextRange

app.activeDocument.textFrames[index].textRange

A range of text in a specific text art item. TextRange gives you access to the text contained in text art items.


app.activeDocument.textFrames[index].textRange.characterAttributes

The character properties for the text range.

CharacterAttributes; read-only.


app.activeDocument.textFrames[index].textRange.characterOffset

Offset of the first character.

Number (long)


app.activeDocument.textFrames[index].textRange.characters

All the characters in this text range.

Characters; read-only.


app.activeDocument.textFrames[index].textRange.characterStyles

All referenced character styles in the text range.

CharacterStyles; read-only.


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

The text string.

String


app.activeDocument.textFrames[index].textRange.end

End index of the text range.

Int32


app.activeDocument.textFrames[index].textRange.insertionPoints

All the insertion points in this text range.

InsertionPoints; read-only.


app.activeDocument.textFrames[index].textRange.kerning

Controls the spacing between two characters, in thousandths of an em. An integer.

Number (long)


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

The length (in characters). Minimum: 0

Number (long)


app.activeDocument.textFrames[index].textRange.lines

All the lines in this text range.

Lines; read-only.


app.activeDocument.textFrames[index].textRange.paragraphAttributes

The paragraph properties for the text range.

ParagraphAttributes; read-only.


app.activeDocument.textFrames[index].textRange.paragraphs

All the paragraphs in this text range.

Paragraphs; read-only.


app.activeDocument.textFrames[index].textRange.paragraphStyles

All referenced paragraph styles in the text range.

ParagraphStyles; read-only.


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

The object’s container.

TextRange; read-only.


app.activeDocument.textFrames[index].textRange.start

Start index of the text range.

Int32


app.activeDocument.textFrames[index].textRange.story

The story to which the text range belongs.

Story; read-only.


app.activeDocument.textFrames[index].textRange.textRanges

All of the text in this text range.

TextRanges; read-only.


app.activeDocument.textFrames[index].textRange.textSelection

The selected text ranges in the text range.

Array of TextRange; read-only.


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

The class name of the object.

String; read-only.


app.activeDocument.textFrames[index].textRange.words

All the words contained in this text range.

Words; read-only.


app.activeDocument.textFrames[index].textRange.changeCaseTo(type)

Changes the capitalization of text

ParameterTypeDescription
typeCaseChangeTypeCapitalization case to change to

Nothing


app.activeDocument.textFrames[index].textRange.deSelect()

Deselects the text range.

Nothing.


app.activeDocument.textFrames[index].textRange.duplicate([relativeObject][, insertionLocation])

Creates a duplicate of this object.

ParameterTypeDescription
relativeObjectObject, optionalObject to duplicate to
insertionLocationElementPlacement, optionalLocation to insert element

TextRange


app.activeDocument.textFrames[index].textRange.getLocalCharOverridesJSON()

Gets json representation of character overrides.

String


app.activeDocument.textFrames[index].textRange.getLocalParaOverridesJSON()

Gets json representation of paragraph overrides.

String


app.activeDocument.textFrames[index].textRange.getParagraphLength()

Gets the length of the first paragraph of the text range.

Int32


app.activeDocument.textFrames[index].textRange.getTextRunLength()

Gets the length of the first text run of the text range.

Int32


app.activeDocument.textFrames[index].textRange.move(relativeObject, insertionLocation)

Moves the object.

ParameterTypeDescription
relativeObjectObjectObject to move element within
insertionLocationElementPlacement, optionalLocation to move element to

TextRange


app.activeDocument.textFrames[index].textRange.remove()

Deletes the object.

Nothing


app.activeDocument.textFrames[index].textRange.select([addToDocument])

Selects the text range.

ParameterTypeDescription
addToDocumentBoolean, optionalWhether to add or replace current selection

Nothing


// Changes size of the first character of each word in the
// current document by changing the size attribute of each character
if ( app.documents.length > 0 ) {
for ( i = 0; i < app.activeDocument.textFrames.length; i++ ) {
var text = app.activeDocument.textFrames[i].textRange;
for ( j = 0 ; j < text.words.length; j++ ) {
//each word is a textRange object
var textWord = text.words[j];
// Characters are textRanges too.
// Get the first character of each word and increase it's size.
var firstChars = textWord.characters[0];
firstChars.size = firstChars.size * 1.5;
}
}
}