TextRange
TextRange
Section titled “TextRange”app.activeDocument.textFrames[index].textRange
Description
Section titled “Description”A range of text in a specific text art item. TextRange gives you access to the text contained in text art items.
Properties
Section titled “Properties”TextRange.characterAttributes
Section titled “TextRange.characterAttributes”app.activeDocument.textFrames[index].textRange.characterAttributes
Description
Section titled “Description”The character properties for the text range.
CharacterAttributes; read-only.
TextRange.characterOffset
Section titled “TextRange.characterOffset”app.activeDocument.textFrames[index].textRange.characterOffset
Description
Section titled “Description”Offset of the first character.
Number (long)
TextRange.characters
Section titled “TextRange.characters”app.activeDocument.textFrames[index].textRange.characters
Description
Section titled “Description”All the characters in this text range.
Characters; read-only.
TextRange.characterStyles
Section titled “TextRange.characterStyles”app.activeDocument.textFrames[index].textRange.characterStyles
Description
Section titled “Description”All referenced character styles in the text range.
CharacterStyles; read-only.
TextRange.contents
Section titled “TextRange.contents”app.activeDocument.textFrames[index].textRange.contents
Description
Section titled “Description”The text string.
String
TextRange.end
Section titled “TextRange.end”app.activeDocument.textFrames[index].textRange.end
Description
Section titled “Description”End index of the text range.
Int32
TextRange.insertionPoints
Section titled “TextRange.insertionPoints”app.activeDocument.textFrames[index].textRange.insertionPoints
Description
Section titled “Description”All the insertion points in this text range.
InsertionPoints; read-only.
TextRange.kerning
Section titled “TextRange.kerning”app.activeDocument.textFrames[index].textRange.kerning
Description
Section titled “Description”Controls the spacing between two characters, in thousandths of an em. An integer.
Number (long)
TextRange.length
Section titled “TextRange.length”app.activeDocument.textFrames[index].textRange.length
Description
Section titled “Description”The length (in characters). Minimum: 0
Number (long)
TextRange.lines
Section titled “TextRange.lines”app.activeDocument.textFrames[index].textRange.lines
Description
Section titled “Description”All the lines in this text range.
Lines; read-only.
TextRange.paragraphAttributes
Section titled “TextRange.paragraphAttributes”app.activeDocument.textFrames[index].textRange.paragraphAttributes
Description
Section titled “Description”The paragraph properties for the text range.
ParagraphAttributes; read-only.
TextRange.paragraphs
Section titled “TextRange.paragraphs”app.activeDocument.textFrames[index].textRange.paragraphs
Description
Section titled “Description”All the paragraphs in this text range.
Paragraphs; read-only.
TextRange.paragraphStyles
Section titled “TextRange.paragraphStyles”app.activeDocument.textFrames[index].textRange.paragraphStyles
Description
Section titled “Description”All referenced paragraph styles in the text range.
ParagraphStyles; read-only.
TextRange.parent
Section titled “TextRange.parent”app.activeDocument.textFrames[index].textRange.parent
Description
Section titled “Description”The object’s container.
TextRange; read-only.
TextRange.start
Section titled “TextRange.start”app.activeDocument.textFrames[index].textRange.start
Description
Section titled “Description”Start index of the text range.
Int32
TextRange.story
Section titled “TextRange.story”app.activeDocument.textFrames[index].textRange.story
Description
Section titled “Description”The story to which the text range belongs.
Story; read-only.
TextRange.textRanges
Section titled “TextRange.textRanges”app.activeDocument.textFrames[index].textRange.textRanges
Description
Section titled “Description”All of the text in this text range.
TextRanges; read-only.
TextRange.textSelection
Section titled “TextRange.textSelection”app.activeDocument.textFrames[index].textRange.textSelection
Description
Section titled “Description”The selected text ranges in the text range.
Array of TextRange; read-only.
TextRange.typename
Section titled “TextRange.typename”app.activeDocument.textFrames[index].textRange.typename
Description
Section titled “Description”The class name of the object.
String; read-only.
TextRange.words
Section titled “TextRange.words”app.activeDocument.textFrames[index].textRange.words
Description
Section titled “Description”All the words contained in this text range.
Words; read-only.
Methods
Section titled “Methods”TextRange.changeCaseTo()
Section titled “TextRange.changeCaseTo()”app.activeDocument.textFrames[index].textRange.changeCaseTo(type)
Description
Section titled “Description”Changes the capitalization of text
Parameters
Section titled “Parameters”Parameter | Type | Description |
---|---|---|
type | CaseChangeType | Capitalization case to change to |
Returns
Section titled “Returns”Nothing
TextRange.deSelect()
Section titled “TextRange.deSelect()”app.activeDocument.textFrames[index].textRange.deSelect()
Description
Section titled “Description”Deselects the text range.
Returns
Section titled “Returns”Nothing.
TextRange.duplicate()
Section titled “TextRange.duplicate()”app.activeDocument.textFrames[index].textRange.duplicate([relativeObject][, insertionLocation])
Description
Section titled “Description”Creates a duplicate of this object.
Parameters
Section titled “Parameters”Parameter | Type | Description |
---|---|---|
relativeObject | Object, optional | Object to duplicate to |
insertionLocation | ElementPlacement, optional | Location to insert element |
Returns
Section titled “Returns”TextRange.getLocalCharOverridesJSON()
Section titled “TextRange.getLocalCharOverridesJSON()”app.activeDocument.textFrames[index].textRange.getLocalCharOverridesJSON()
Description
Section titled “Description”Gets json representation of character overrides.
Returns
Section titled “Returns”String
TextRange.getLocalParaOverridesJSON()
Section titled “TextRange.getLocalParaOverridesJSON()”app.activeDocument.textFrames[index].textRange.getLocalParaOverridesJSON()
Description
Section titled “Description”Gets json representation of paragraph overrides.
Returns
Section titled “Returns”String
TextRange.getParagraphLength()
Section titled “TextRange.getParagraphLength()”app.activeDocument.textFrames[index].textRange.getParagraphLength()
Description
Section titled “Description”Gets the length of the first paragraph of the text range.
Returns
Section titled “Returns”Int32
TextRange.getTextRunLength()
Section titled “TextRange.getTextRunLength()”app.activeDocument.textFrames[index].textRange.getTextRunLength()
Description
Section titled “Description”Gets the length of the first text run of the text range.
Returns
Section titled “Returns”Int32
TextRange.move()
Section titled “TextRange.move()”app.activeDocument.textFrames[index].textRange.move(relativeObject, insertionLocation)
Description
Section titled “Description”Moves the object.
Parameters
Section titled “Parameters”Parameter | Type | Description |
---|---|---|
relativeObject | Object | Object to move element within |
insertionLocation | ElementPlacement, optional | Location to move element to |
Returns
Section titled “Returns”TextRange.remove()
Section titled “TextRange.remove()”app.activeDocument.textFrames[index].textRange.remove()
Description
Section titled “Description”Deletes the object.
Returns
Section titled “Returns”Nothing
TextRange.select()
Section titled “TextRange.select()”app.activeDocument.textFrames[index].textRange.select([addToDocument])
Description
Section titled “Description”Selects the text range.
Parameters
Section titled “Parameters”Parameter | Type | Description |
---|---|---|
addToDocument | Boolean, optional | Whether to add or replace current selection |
Returns
Section titled “Returns”Nothing
Example
Section titled “Example”Manipulating Text
Section titled “Manipulating Text”// 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; } }}