3 Replies Latest reply on Sep 3, 2009 11:24 AM by theBinki

    richtextarea font issues

    theBinki Level 1

      Hello, all.

       

      I have a Flex 3 application that uses a richtextarea for editing text.  For example, they set the font to 10, looks pretty good.  This is 10 'pixels' according to the Flex documentation.  The richtexteditor font drop down list is an array of fonts from 8 to 72 in various increments.  So, we have a font setting of 10.  When the user goes to print it, they hit my View PDF button.  A service sticks the text in a database, the ID is returned and the result handler fires off a URLRequest to a Cold Fusion page, opening a new browser window, passing in the the returned ID via URL.  The CF page uses the ID to get the report and then processes it using CFDocument.  It loads no problem.  Formats and is pretty fast.  Therein lies my problem.

       

      When the richtextarea htmltext (formatted in HTML) is saved, it is a big glob in a text field.  No problem.  But when the cfdocument gets it, it has the stored font size of '10'.  This is HUGE in CFDocuments output as CFDocument supports HTML 4 sizes (1-7) and the vaious relative sizes based on the basefont (like size = "-2").

       

      Anyone have any idea how to print something in the richtextarea to a PDF that does not require some big search and replace of the size = "10" (or x, whatever size the user selected) with size = "2" (or y, or whatever would be mapped to the original size).

       

      I also tried AlivePDF library, but it breaks the pages in strange places.  First 2 pages are ok, others then break in mid-sentence.  I monkeyed with it, but don't have time to dig around in the code.  Thanks.

       

      Gary

        • 1. Re: richtextarea font issues
          Flex harUI Adobe Employee

          Should be a regular expression search and replace.  I don't think there's a way around it.

           

          Alex Harui

          Flex SDK Developer

          Adobe Systems Inc.

          Blog: http://blogs.adobe.com/aharui

          1 person found this helpful
          • 2. Re: richtextarea font issues
            theBinki Level 1

            Hi.  Thanks for replying.  Well, I unded up using cf's replace string function.  Essentially:

             

            ::run the query, put the result in a variable called theReportText, parse it, put the results in the cfdocument.

             

             

            <!--- HTML 4.0 font sizes --->

            <cfset

             

             

             

            size1 = 'SIZE="1"'>

            <cfset

             

             

             

            size2 = 'SIZE="2"'>

            ...

            <cfset

             

             

             

            size7 = 'SIZE="7"'>

             

             

            <!--- RichTextEditor font sizes in pixels --->

            <cfset

             

             

             

            size8 = 'SIZE="8"'>

            <cfset

             

             

             

            size9 = 'SIZE="9"'>

            ...

            <cfset

             

             

             

            size72 = 'SIZE="72"'>

             

             

            <cfset

             

             

             

            theReportText = replace(#theReportText#, size8, size1, "All") >

            <cfset

             

             

             

            theReportText = replace(#theReportText#, size9, size1, "All") >

            ...

            <cfset

             

             

             

            theReportText = replace(#theReportText#, size72, size7, "All") >

             

             

             

            Ugly, but it worked.  The reports are mainly small.

             

             

             

            Some things I did notice:

             

             

             

            I am using the GEMVC.  In my application, the user runs a report in a popup window.  The result is stored in model.reportResult. model.reportResult is bound to the richTextEditor in the main application.  I process the results a bit when the data is first retrieved, doing some formatting (using the HTML tags that the editor can recognize).  They can see the result before clicking ok.  When they click ok, they are taken back to the main app. and the text shows up in the richTextEditor.  The user can edit the returned results.  They can switch to a preview tab to see the completed report look.  (This is because there is another text editor that lets them add 'appended' text to the report results).

             

             

             

            Something I noticed was that when you first get the query results and they are bound to the richTextEditor control, the control does not 'parse and format' the result.  However, if you type or click any of the formatting buttons, the text is parsed and formatted with all the <textformat>, etc. tags.  This has a wierd effect of me.  If the user runs the report, does not make any changes to the text in the richTextEditor, goes to preview, clicks view PDF, they see one format with more spacing between the lines, etc.  However, if you then go back and type even a space in the richTextArea, it fires the formatting.  If you then go view the PDF, every thing is much tighter because the text formatting takes place.  Just a quirk, but I am struggling to make it consistent.

             

             

             

            Thanks, again.

             

             

             

            Gary

             

             

             

             

            • 3. Re: richtextarea font issues
              theBinki Level 1

              Ugh, even this does not format things correctly.