Error importing HTML

4 posts, 0 answers
  1. wang
    wang avatar
    2 posts
    Member since:
    Mar 2018

    Posted 06 Mar Link to this post

    Hi,

    The requirement is converting HTML string into RadDocument xaml string, so I take the docs from

    https://docs.telerik.com/devtools/document-processing/libraries/radwordsprocessing/formats-and-conversion/html/htmlformatprovider#export

    and wrote the code as follow:

                HtmlFormatProvider provider = new HtmlFormatProvider();
                XamlFormatProvider provider2 = new XamlFormatProvider();
                RadDocument document = provider.Import(html);
                string xaml = provider2.Export(document);
                return xaml;

    the error pops in line 3:

    "The type initializer for 'Telerik.Windows.Documents.UI.TextDecorations.DecorationProviders.UnderlineTypes' threw an exception."

    How to solve this?

    Thanks,

    Rain

     

  2. Tanya
    Admin
    Tanya avatar
    736 posts

    Posted 08 Mar Link to this post

    Hello Wang,

    I checked the implementation of the UnderlineTypes class but couldn't find why it might throw an exception. The issue you are observing is most probably related to something specific in the document content, so I would like to ask you to share a sample document reproducing the error, if possible, so we can test it locally.

    On a side note, I noticed that the API used in the code snippet is the one of RadRichTextBox instead of RadWordsProcessing, so I am moving the thread in the RadRichTextBox for WPF forum.

    Regards,
    Tanya
    Progress Telerik

  3. wang
    wang avatar
    2 posts
    Member since:
    Mar 2018

    Posted 21 Mar Link to this post

    I've tried using '123' for the html variable, same error.
  4. Tanya
    Admin
    Tanya avatar
    736 posts

    Posted 23 Mar Link to this post

    Hello Wang,

    I tested again the scenario but I am still unable to reproduce an issue with it. I am attaching a sample project - could you please check it and let me know if I am missing something? How does it work on your end?

    Regards,
    Tanya
    Progress Telerik
    Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
Back to Top