Skip to main content
Participant
Jan 28, 2011 12:09 PM UTC
Answered

get text from TextLine

How do I actually get the text that is rendered in a TextLine object?

I just can't find it, though im quite sure I overlooked something.

This topic is closed to new replies. Start a new post to keep the conversation going.
robin_briggsCorrect answer
Adobe Employee
Jan 28, 2011 6:45 PM UTC

If the TextLine was created by TLF, then its userData property should be a TextFlowLine. The TextFlowLine has an absoluteStart, which tells you where in the TextFlow it starts, and a textLength. The TextFlowLine also has a paragraph. From the paragraph you can get the TextFlow, and the TextFlow has a getText() method for getting the text.

So, putting this all together, something like this should work:

var textFlowLine:TextFlowLine = textLine.userData as TextFlowLine;

var textFlow:TextFlow = textFlowLine.paragraph.getTextFlow();

var textOfLine:String = textFlow.getText(textFlowLine.absoluteStart, textFlowLine.absoluteStart + textFlowLine.textLength);

- robin

1 reply

robin_briggsCorrect answer
Adobe Employee
Jan 28, 2011 6:45 PM UTC

If the TextLine was created by TLF, then its userData property should be a TextFlowLine. The TextFlowLine has an absoluteStart, which tells you where in the TextFlow it starts, and a textLength. The TextFlowLine also has a paragraph. From the paragraph you can get the TextFlow, and the TextFlow has a getText() method for getting the text.

So, putting this all together, something like this should work:

var textFlowLine:TextFlowLine = textLine.userData as TextFlowLine;

var textFlow:TextFlow = textFlowLine.paragraph.getTextFlow();

var textOfLine:String = textFlow.getText(textFlowLine.absoluteStart, textFlowLine.absoluteStart + textFlowLine.textLength);

- robin

Translate