Unplanned
Last Updated: 23 Oct 2019 07:53 by ADMIN
Martin
Created on: 23 Oct 2019 07:53
Category: RichTextBox
Type: Feature Request
1
RichTextBox: Improve HTML export to perform font-size export in different units
HTML export of RadRichTextBox to perform font-size export in different units.

If you export a document using the HtmlFormatProvider, all style properties which contain measurement units are exported in pixel units. This makes the exported documents look much smaller when opened on devices with higher pixel density.

WORKAROUND: use Regex to find, convert and replace the font-size attributes

            HtmlFormatProvider html = new HtmlFormatProvider();
            string res = html.Export(document);
            Regex regex = new Regex(@"font-size: [0-9]*\.?[0-9]*px");
            Match match = null;

            do
            {
                match = regex.Match(res);
                if (!match.Success)
                {
                    break;
                }

                string value = match.Value.Substring("font-size: ".Length, match.Value.Length - "font-size: ".Length - "px".Length);
                double pts = double.Parse(value) * 72 / 96;
                res = res.Replace(match.Value, @"font-size: " + Math.Round(pts, 4) + "pt");
            } while (match.Success);

            File.WriteAllText("output.html", res);
0 comments