Rich Text Rendering Discrepancy

Silverlight

Collaborate with ComponentOne technical experts and fellow developers.

Rich Text Rendering Discrepancy

  • rated by 0 users
  • This post has 5 Replies |
  • 1 Follower
  • Working on a SL 3 app which allows users to build advertisements (typically destined for print media) consisting of images and rich text built in a WYSIWYG editor on screen.  The text is entered using the C1RichTextBox.  Once users finish their ad on screen, we produce a print-ready PDF of the ad.  It is critical to our app that the PDF match what the users sees on screen from a layout standpoint.

    The problem we are facing is that the C1RichTextBox renders the text differently than what we are used to seeing.  Specifically we've noticed that it tends to use tighter character-spacing and greater line-spacing than we are used to seeing in other environments, including the PDFs we produce.  The PDF engine we're using uses the Internet Explorer HTML rendering engine to import HTML into PDFs.  For instance, if we take the HTML that gets exported from the C1 tool and render it in Internet Explorer, it renders with looser character-spacing and tighter line-spacing in IE than how it appears in Silverlight using the C1RichTextBox by default.

    Can someone tell me what causes these differences, and whether it is possible for us to change the default behavior to match the way that IE renders HTML?

  • It's pretty much impossible for us to render text exactly the same as Internet Explorer. We depend on Silverlight's font rendering. Printing exactly what is seen in the C1RichTextBox will be possible in SL4, we will release a sample of this when we release the SL4 version of the controls. Also, we will add PDF export to the RichTextBox, but it has several limitations. It only supports PDF's built-in fonts and it doesn't support Unicode.
  • Not exactly what I was hoping ot hear, but I understand why it is the way it is.  Thanks for the response.

    My goal isn't specifically to render identically to IE, but more directly to find a way to precisely duplicate on-screen text in a SL app (or more specifically in a C1RishTextBox) into a PDF document that is conducive for commercial printing.  By "conducive to printing" I mean the following:

    • The document is in the CMYK colorspace as opposed to RGB.
    • There is actual text in the document as opposed to a rasterization of text.
    • All fonts are embedded in the document.

    I looked at your C1PDF control.  The fonts limitation would be a show-stopper for us.  However, being able to "print exactly what is seen" might be helpful if we could find a way to print to a stream or to PDF.  Is this something that C1 will be adding, or are you referring to functionality that will be inherent in SL4?

    Could you tell me whether Silverlight font rendering is based on the WPF Text Engine?

    Also, I believe one of my developers has found a way to control line-spacing in the C1RichText control, but is still looking for a way to control character-spacing.  I found a FontStretch property (http://msdn.microsoft.com/en-us/library/system.windows.controls.control.fontstretch.aspx).  IS this something we might be able to use to control the character-spacing in the C1RichText control.  If not, is there another way to control this?

  • C1Guest_1150257:
    Is this something that C1 will be adding, or are you referring to functionality that will be inherent in SL4?

    I'm referring to the functionality included in SL4. This functionality will not serve your purpose because SL4 prints a bitmap, so the actual text is not in the document.

    We might support custom fonts in C1PDF in the future. Your application would have to provide the fonts that are embedded in the document. Would that work for you?

    C1Guest_1150257:
    Could you tell me whether Silverlight font rendering is based on the WPF Text Engine?

    I don't know.

    C1Guest_1150257:
    Also, I believe one of my developers has found a way to control line-spacing in the C1RichText control, but is still looking for a way to control character-spacing.  I found a FontStretch property (http://msdn.microsoft.com/en-us/library/system.windows.controls.control.fontstretch.aspx).  IS this something we might be able to use to control the character-spacing in the C1RichText control.  If not, is there another way to control this?

    You can control the line spacing using the C1TextElement.LineHeight property. But I'm not sure you would be able to get it to look exactly like in IE. The baseline of the fonts will still be different. FontStretch doesn't do anything in SL (here they claim it works with some fonts, but I haven't been able to test this).

  • C1_MaxM:
    We might support custom fonts in C1PDF in the future. Your application would have to provide the fonts that are embedded in the document. Would that work for you?

    That would help.  Outside of that issue, C1PDF seems to do most of what we need.  Unfortunately, our current timeline doesn't allow for us to wait.

    C1_MaxM:
    FontStretch doesn't do anything in SL

    That's dissappointing, especially since MSDN actually has a FontStretch page (http://msdn.microsoft.com/en-us/library/system.windows.controls.control.fontstretch(VS.95).aspx) dedicated to how this property is implemented for SL 3.

    One of our developers is working on a process that will theoretically allow us to replicate what the user sees on screen into a PDF ver closely if not exactly.  I will try to remember to post the results of our endeavor here.  Thanks again for all the info.

  • We already have the PDF export, maybe we can send you a private build and you act as early adopter of this component.

    Would it work for you?

    <update>
    The version we have under construction doesn't support embeded fonts. So, it won't work in you case, if you are using font families that are not the standard PDF ones. Sorry for my misunderstanidng.
    </update>
     
    Regards

    Follow me: Twitter.com/leovernazza/

Page 1 of 1 (6 items)