Skip to main content
Participant
January 28, 2011
Answered

get text from TextLine

  • January 28, 2011
  • 1 reply
  • 738 views

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 has been closed for replies.
Correct answer robin_briggs

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
January 28, 2011

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