Completed
Last Updated: 02 Aug 2024 11:09 by ADMIN
Release 2024.3.802 (2024 Q3)
Janson
Created on: 04 Jul 2024 11:52
Category: WordsProcessing
Type: Bug Report
1
WordsProcessing: Import from HTML doesn't apply style from class names in CSS

Latest version 2024.2.426:

Old version 2022.3.906:

Use the following code: 

        static void Main(string[] args)
        {
            Console.WriteLine("Test from 2022.3.906 to 2024.2.426.");
            string html = @"<html>
                <head>
                    <style type=""text/css"">
                            h1 {
                               background-color: red;
                              }
                            #highlight1{
                                background-color: blue;
                             }
                           .highlight2{
                                background-color: yellow;
                             }
                     </style>
                </head>
                <body>
                   <h1>H1 - This Works </h1>
                   <h2 id=""highlight1"">H2 with id selector.  This works too.</h2>
                   <h3 class=""highlight2"">H3 with class selector.  This didn't work</h3>
                </body>
                </html>";

            Telerik.Windows.Documents.Flow.FormatProviders.Html.HtmlFormatProvider html_provider = new Telerik.Windows.Documents.Flow.FormatProviders.Html.HtmlFormatProvider();
            RadFlowDocument document = html_provider.Import(html);

            string html_output = "output.html";
            using (Stream output = File.Create(html_output))
            {

                html_provider.Export(document, output);
            }
            Process.Start(new ProcessStartInfo() { FileName = html_output, UseShellExecute = true });
        }
0 comments