Skip to main content
Known Participant
September 10, 2009
Question

how to convert the old text.htmlText to the new TLF format?

  • September 10, 2009
  • 1 reply
  • 2580 views

Hi,

... we store in the database htmlText, which were created with the old RichTextEditor... and nowadays we moved to the new TLF.

The problem is that on the client side I can't import a bit more complex text to a textflow, which one was created with the old RichTextEditor.

textFlow = TextFilter.importToFlow(htmlText, TextFilter.HTML_FORMAT)


.... I'm interested in any kind of solution. 😃

thx

This topic has been closed for replies.

1 reply

Adobe Employee
September 10, 2009

Is part of your problem that you are trying to append new htmlText onto the end of an existing TextFlow? One way you could handle this would be to take the TextFlow you create from the html, and paste it to the end of the existing TextFlow. Here's what that might look like:

     var htmlFlow:TextFlow = TextConverter.importToFlow(htmlText, TextConverter.HTML_FORMAT);

     IEditManager(textFlow.interactionManager).pasteTextScrap(new TextScrap(htmlFlow), new SelectionState(textFlow, textFlow.textLength, textFlow.textLength));

We've been making changes to the HTML text converter recently to make it work better with the old TextField type htmlText. I would suggest getting a new build, and trying it out. There are some advanced html features that were part of the TextField htmlText that we don't yet handle (for example floats & lists). But in general, if you see incompatibilities between what you used to get and what you get now, please let us know.

Thanks!

- robin

Known Participant
September 11, 2009

hi Robin,

I do not want to append htmlText onto the end of an existing TextFlow.

I want to create the a new textFlow from an earlier saved htmlText and I do not want to create it element by element looping trough the saved text.

public function set htmlText(htmlText:String):void
{

    if (!htmlText)
         return;

    try{textFlow = TextFilter.importToFlow(htmlText, TextFilter.HTML_FORMAT);}
//  try{textFlow = TextFilter.importToFlow(htmlText, TextFilter.TEXT_LAYOUT_FORMAT);}

     catch(e:Error){}
    if (!textFlow)
    {
        dispatchEvent(new Event(KILL_ME));
        return trace('        TextEditor.htmlText    killMe    ... switch back to old text editor...');
    }
    textFlow.fontLookup = FontLookup.EMBEDDED_CFF;
    textFlow.renderingMode = RenderingMode.CFF;
    addLiseners();
}

and if I set the htmlText property

htmlText = '<TEXTFORMAT LEADING="2"><P ALIGN="LEFT"><FONT FACE="Calibri" SIZE="127" COLOR="#0B333C" LETTERSPACING="0" KERNING="0">Default text 1234</FONT></P></TEXTFORMAT>';

htmlText = '<P><FONT SIZE="167" FACE="Calibri">Write Here</FONT></P>';

than the textFlow will be null

... and I would like to have simple converter...

Participating Frequently
September 16, 2009

Péter,

Some of the attributes supported by TextField.htmlText are not supported in TLF's HTML_FORMAT (letterspacing, kerning, leading etc.).

You can instruct the HTML importer to simply log these unsupported attributes as errors and continue parsing by doing something like:

var parser:ITextImporter =  TextConverter.getImporter(TextConverter.HTML_FORMAT);

parser.throwOnError =  false;

var textFlow:TextFlow =  parser.importToFlow(source);

// textFlow should be non-null unless some fatal error was encountered. You can examine the errors in  parser.errors

Hope this helps.

Abhishek

(Adobe Systems Inc.)