HtmlFormatProvider Italics

2 posts, 0 answers
  1. Chris Ward
    Chris Ward avatar
    56 posts
    Member since:
    Jan 2010

    Posted 20 May 2015 Link to this post

    The question is about the output of this code:

    Telerik.WinForms.Documents.FormatProviders.Html.HtmlFormatProvider fmt =
        new Telerik.WinForms.Documents.FormatProviders.Html.HtmlFormatProvider();
    fmt.ExportSettings.StylesExportMode = Telerik.WinForms.Documents.FormatProviders.Html.StylesExportMode.Inline;
    RadDocument rad = fmt.Import("The following word is <i>italic</i>.");
    string html = fmt.Export(rad);

    The HTML output contains:

    <span style="font-family: 'Times New Roman';font-style: Italic;font-size: 16px;">italic</span>

    It seems as though some HTML parsers don't regard "font-style: Italic" as a valid font-style. However, if I replace it with "font-style: italic" it works just fine. The client in question is GMail's HTML email viewer, but I'm sure there are others.

    The only standard I can find related to this is the SVG 1.1 standard which states:

    Keyword values, such as italic in font-style="italic", are also case-sensitive and must be specified using the exact case used in the specification which defines the given keyword. Section 6.7 Paragraph 2

    Obviously the DOCTYPE is xhtml, not an SVG file, but the premise that certain standards expect this particular word to be lowercase lends to the fact that in certain situations "Italic" vs. "italic" does matter.

     For the time being I'll just manually replace this substring in all of my HTML documents, but it would be nice if the RadDocument / HtmlFormatProvider guys could implement a permanent fix for this.

  2. Hristo
    Hristo avatar
    1522 posts

    Posted 21 May 2015 Link to this post

    Hello Chris,

    Thank you for writing.

    Indeed this is how a RadDocument gets exported to HTML. At the moment, if you would like to have the italic property start with a lower case you would need to manually change it. I think the easiest way would be to use a Regex: 
    RadDocument rad = fmt.Import("The following word is <i>Italic</i>.");
    string html = fmt.Export(rad);
    string pattern = "font-style: Italic";
    string replace = "font-style: italic";
    string result = Regex.Replace(html, pattern, replace);

    I hope this helps. Should you have further questions please do not hesitate to write back.

    Hristo Merdjanov
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top