Skip to main content
Participant
June 4, 2009
Answered

export text from textflow

  • June 4, 2009
  • 1 reply
  • 959 views

I have a custom editor built in flash that I want to convert to the Text Layout Framework.

I have all contents in containers, but when I do an export to XML, I want to know what content was displayed in what container.

I tried to do this by going through al the textlines in the textflow; I can get all textline objects, but cannot get to the content and the formatting information.

Could anyone give me a hint on how to do this? I would already be happy if I could do a separate export for each container.

Thanks for your reply!

Arend.

This topic has been closed for replies.
Correct answer robin_briggs

Do you have a TLF TextFlow with multiple linked containers, and you want to export each container as an independent TextFlow? If so, I would suggest copying the text from each container into a separate TextFlow, and then exporting the resulting TextFlow. You can iterate through the containers in the IFlowComposer, and for each container, create a new TextFlow by calling deepCopy on it. I expect the code might look something like this:

var pos:int = 0;

for (var i:int = 0; i < textFlow.flowComposer.numControllers; i++)

{

     var controller:ContainerController = textFlow.flowComposer.getControllerAtIndex(i);

     var newTextFlow:TextFlow = textFlow.deepCopy(pos, pos + controller.textLength);

     var exportedXML:XML = TextFilter.export(newTextFlow, TextFilter.TEXT_LAYOUT_FORMAT, ConversionType.XML_TYPE);

     pos += controller.textLength;

}

This is coded from memory, and I haven't compiled it or tested it, but it should give you an idea how to do it. If I've misunderstood your question, please let me know.

- robin

1 reply

robin_briggsCorrect answer
Adobe Employee
June 5, 2009

Do you have a TLF TextFlow with multiple linked containers, and you want to export each container as an independent TextFlow? If so, I would suggest copying the text from each container into a separate TextFlow, and then exporting the resulting TextFlow. You can iterate through the containers in the IFlowComposer, and for each container, create a new TextFlow by calling deepCopy on it. I expect the code might look something like this:

var pos:int = 0;

for (var i:int = 0; i < textFlow.flowComposer.numControllers; i++)

{

     var controller:ContainerController = textFlow.flowComposer.getControllerAtIndex(i);

     var newTextFlow:TextFlow = textFlow.deepCopy(pos, pos + controller.textLength);

     var exportedXML:XML = TextFilter.export(newTextFlow, TextFilter.TEXT_LAYOUT_FORMAT, ConversionType.XML_TYPE);

     pos += controller.textLength;

}

This is coded from memory, and I haven't compiled it or tested it, but it should give you an idea how to do it. If I've misunderstood your question, please let me know.

- robin

arendkAuthor
Participant
June 5, 2009

Hi Robin,

You are a genius! This is what I needed.

Two other things that come up:

1. it should be possible to do a similar thing for individual text lines, but I don't understand how to calculate the position in the textflow from the data in the TextLine object.

Could you tell me how to do this?

2. is it possible to tell the flowcomposer to put a certain part of the flow into a certain container?

Arend.

Adobe Employee
June 8, 2009

A TextFlowLine has a absoluteStart property, which is the index of the text at the start of the line, as an offset from the start of the TextFlow. A TextFlowLine also has a textLength property, which is the number of characters in the line. Once the text has been displayed in the container, you can get the textFlowLine from the TextFlow's flowComposer by calling findLineAtPosition(). And you can iterate all the lines in the TextFlow with the flowComposer, by calling getLineAt:

   for (var lineIndex:int = 0; lineIndex < flowComposer.numLines; lineIndex++)

          var line:TextFlowLine = flowComposer.getLineAt(lineIndex);

Unfortunately we don't have any way to control the text that goes into a container -- it will fill up the first container, then go on to the next, etc. I'm sorry; I think this is definitely something we should consider for later.

Hope this helps,

- robin