Skip to main content
Participant
August 18, 2009
Question

Whitespace issue on Textlayout Framework export to string

  • August 18, 2009
  • 1 reply
  • 1458 views

Hello,

I'm using Text Layout Framework running on Flex 3.2.  I'm trying to export the contents of a editable textFlow area as a string that retains full white space information, but that doesn't seem to be working.  For instance, if there are two white spaces after a period in between different spans (let's say I bold some text, or change the font), they ends up getting truncated out in the export to string.  This is the code that I'm using to perform the export in my editor.

public function get text():String {

     return TextFilter.export(_textFlow, TextFilter.PLAIN_TEXT_FORMAT, ConversionType.STRING_TYPE ).toString();

}

So, is there some code I need to be inserting that I haven't considered as of yet?  I've done my best to turn the WhiteSpaceCollapse property of a given textflow to "preserve", but I believe that's applicable for import, not export.
Thanks for the help!
Justin

This topic has been closed for replies.

1 reply

Adobe Employee
August 19, 2009

You need to wrap the export code.  Our sample application does it like this:

static private const xmlBoilerPlate:String = '<?xml version="1.0" encoding="utf-8"?>\n';

public function export(format:String) : void

{

{

var originalSettings:Object = XML.settings();

try

{

XML.ignoreProcessingInstructions = false;

XML.ignoreWhitespace = false;

XML.prettyPrinting = false;

var exporter:ITextExporter = TextConverter.getExporter(format);

var xmlExport:XML = exporter.export(defaultFlow, ConversionType.XML_TYPE) as XML;

XML.setSettings(originalSettings);

}

catch(e:Error)

{

XML.setSettings(originalSettings);

throw(e);

}

}

Sorry for the bad indent - hope that helps.

Richard

Participant
August 19, 2009

Looking through my available methods, I don't seem to have TextConverter available.  I have included, textLayout_conversion.swc, textLayout_core.swc, and textLayout_edit.swc.  Am I using too old of a version of text layout framework?

Also, I noticed that your function takes (format:String) as an input.  I'm trying to write a method that converts a type TextFlow into a String.

Am I misunderstanding things?

Thx,

Justin

Participating Frequently
August 19, 2009

In older builds, the TextConverter class was called TextFilter. You probably have that in textLayout_conversion.swc, which you could confirm by unzipping the SWC and looking at its catalog.xml file.

Gordon Smith

Adobe Flex SDK Team