This is a migrated thread and some comments may be shown as answers.

Error importing HTML

3 Answers 105 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
wang
Top achievements
Rank 1
wang asked on 06 Mar 2018, 09:34 AM

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

 

3 Answers, 1 is accepted

Sort by
0
Tanya
Telerik team
answered on 08 Mar 2018, 02:17 PM
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

0
wang
Top achievements
Rank 1
answered on 21 Mar 2018, 07:27 AM
I've tried using '123' for the html variable, same error.
0
Tanya
Telerik team
answered on 23 Mar 2018, 04:43 PM
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.
Tags
RichTextBox
Asked by
wang
Top achievements
Rank 1
Answers by
Tanya
Telerik team
wang
Top achievements
Rank 1
Share this question
or