• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
Locked
0

Preserving whitespace when importing an html String into a RichText

Guest
Apr 27, 2011 Apr 27, 2011

Copy link to clipboard

Copied

Brief situation overview:

     The program allows the user to edit RichTextEditors and other classes in order to create presentable documents. The program handles printing the document so when the user wants a print preview or to actually print they select that option from the program's menu. Calling a print preview requests the printable data from all the elements in the document and puts them into formats that look more presentable (without editing controls).

Problem:

     When the RichTextEditor's htmltext is retrieved it gets imported into an instance of RichText but the whitespace gets collapsed.

Example:

This (in RTE):

     Table

     Key     Value

     1         2

     3         4

     5         6

Becomes (in RT):

     Table

     Key Value

     1 2

     3 4

     5 6

Relevant code:

     if(data is String) {

          var curElem:RichText = new RichText();

          var importer:ITextImporter = TextConverter.getImporter(TextConverter.TEXT_FIELD_HTML_FORMAT);

          curElem.textFlow = importer.importToFlow(data);

          //Some curElem.textFlow leaf color and baselineShift changes

          addToPage(curElem);

     } else ...

What I've tried/noticed:

     I have tried putting in

          XML.ignoreProcessingInstructions = false;

          XML.ignoreWhitespace = false;

          XML.prettyPrinting = false;

     and

          curElem.textFlow.whiteSpaceCollapse = WhiteSpaceCollapse.PRESERVE;

     before the importer.importToFlow() function gets called but it hasn't changed the results at all. Although changing the textFlow.whiteSpaceCollapse value wouldn't have done anything since the importer just creates a new textFlow (I thought I'd mention that I tried it anyway). When I tracked the values for XML that I changed during this process I made sure that they weren't getting reset to true at some point. Having said that I didn't do a depth step through the whole importToFlow() call so if it reset the values and changed them back (I don't know why it would do that) I probably wouldn't have noticed.

Sorry if I'm unclear about anything, if you need any more information then please let me know.

-Devin

TOPICS
Text layout framework

Views

6.2K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Adobe Employee , May 02, 2011 May 02, 2011

I have logged a bug of TEXT_FIELD_HTML_FORMAT importer.

Thanks for your report.

Votes

Translate

Translate
Adobe Employee ,
Apr 27, 2011 Apr 27, 2011

Copy link to clipboard

Copied

Firstly, TLF now does not support *Table*. If you import an html string including <tr> <td>, those tags will be ignored and all the data in <td> and <tr> will be showed in one line.

If you meet some other problems,  pls attach the html string you import.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Apr 27, 2011 Apr 27, 2011

Copy link to clipboard

Copied

Sorry I didn't mean by writing Table in there that I was indicating any html table tags, only that the example should resemble two columns that are spaced apart using space or tab characters.

To try to be more clear here is the String for data (I took out the word table):

<TEXTFORMAT LEADING="2"><P ALIGN="LEFT"><FONT FACE="Arial" SIZE="12" COLOR="#000000" LETTERSPACING="0" KERNING="0">Key   Value</FONT></P></TEXTFORMAT><TEXTFORMAT LEADING="2"><P ALIGN="LEFT"><FONT FACE="Arial" SIZE="12" COLOR="#000000" LETTERSPACING="0" KERNING="0">1       2</FONT></P></TEXTFORMAT><TEXTFORMAT LEADING="2"><P ALIGN="LEFT"><FONT FACE="Arial" SIZE="12" COLOR="#000000" LETTERSPACING="0" KERNING="0">3       4</FONT></P></TEXTFORMAT><TEXTFORMAT LEADING="2"><P ALIGN="LEFT"><FONT FACE="Arial" SIZE="12" COLOR="#000000" LETTERSPACING="0" KERNING="0"></FONT></P></TEXTFORMAT><TEXTFORMAT LEADING="2"><P ALIGN="LEFT"><FONT FACE="Arial" SIZE="12" COLOR="#000000" LETTERSPACING="0" KERNING="0">5       6</FONT></P></TEXTFORMAT>

Which should look like (as it does in the RTE):

Key   Value

1       2

3       4

5       6

Looks like (in the RT):

Key Value

1 2

3 4

5 6

Also, the empty line was intentional. I wanted to add some more varied input at the time.

-Devin

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Employee ,
Apr 27, 2011 Apr 27, 2011

Copy link to clipboard

Copied

It seems a bug. Let us double check it.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Employee ,
May 02, 2011 May 02, 2011

Copy link to clipboard

Copied

I have logged a bug of TEXT_FIELD_HTML_FORMAT importer.

Thanks for your report.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Employee ,
Jul 31, 2011 Jul 31, 2011

Copy link to clipboard

Copied

Pls make your code as follows, then the whitespace will be preserved.

var format:TextLayoutFormat = new TextLayoutFormat();
format.whiteSpaceCollapse = WhiteSpaceCollapse.PRESERVE;
var config:Configuration = new Configuration();
config.textFlowInitialFormat = format;


var importer:ITextImporter = TextConverter.getImporter(TextConverter.TEXT_FIELD_HTML_FORMAT, config);

var textFlow:TextFlow = importer.importToFlow(markup);

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 12, 2011 Aug 12, 2011

Copy link to clipboard

Copied

Hello,

This doesn't seem to work for me. I'm using the 4.1 SDK.

My markup looks like: "       abc".

Here are my settings:

var format:TextLayoutFormat=new TextLayoutFormat();
format.whiteSpaceCollapse=WhiteSpaceCollapse.PRESERVE;
               
var config:Configuration=new Configuration();
config.textFlowInitialFormat=format;
               
var importer:ITextImporter=TextConverter.getImporter(TextConverter.TEXT_FIELD_HTML_FORMAT,config);

But what gets shown is "abc".

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Employee ,
Aug 12, 2011 Aug 12, 2011

Copy link to clipboard

Copied

It works for me... I think you need at least TLF 2.0.0.232.

Our fixes will only be in the new version.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 16, 2011 Aug 16, 2011

Copy link to clipboard

Copied

Hi,

Sorry for the dumb question, but how do I find out what the exact version of my TLF is?

Thank you.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Employee ,
Aug 16, 2011 Aug 16, 2011

Copy link to clipboard

Copied

Have a look at \frameworks\rsls folder under the Flex SDK you are using.

In SDK 4.5, there is a textLayout_2.0.0.232.swf. It means build 232 of TLF 2.0.

PS:

In some old threads of this forum, there are methods about how to replace TLF lib in Flex SDK.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Apr 09, 2012 Apr 09, 2012

Copy link to clipboard

Copied

LATEST

this is the way to solve this bug and no need for changing any xml settings , simple and it works

exporting the textflow:

var richTextXML:xml = new XML("<"+"richTextXML"+"/>");

richTextXML.appendChild(getCdataXMl());

private function getCdataXMl():xml{

  var textFlowStr:String = TextConverter.export(textFlow,TextConverter.TEXT_FIELD_HTML_FORMAT

, ConversionType.STRING_TYPE).toString();

var textFlowXMl:xml = new XMl("<![CDATA["+textFlowStr+"]]>");

return textFlowXMl;

}

importing TextFlow from XMl :

var htmlTextInStr:String = richTextXMl.text();

var importtedTextFlow:TextFlow = TextConverter.importToFlow(htmlTextInStr,TextConverter.TEXT_FIELD_HTML_FORMAT);

textArea.textFlow = importtedTextFlow;

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines