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

Import HTML - Images...

1 Answer 175 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
ITA
Top achievements
Rank 1
ITA asked on 26 Jun 2012, 08:56 AM
Hi,

i'm workink with the wpf q2 2012 rad controls. I want to load a html in the RichTextBox named "editor". I can load text
byte[] _Buffer = null;
_Buffer = FileToByteArray(test.html);
editor.Document = provider.Import(_Buffer);

So far ok, but all the images are not shown. How to use the LoadImageFromUrl Event? Can't find a working example.
And the second problem are the german words with "ä", "ü", "ö",.. They are shown as question mark.
Thanks
Regards
Rene

1 Answer, 1 is accepted

Sort by
0
Iva Toteva
Telerik team
answered on 29 Jun 2012, 12:09 PM
Hello Rene,

HtmlFormatProvider loads images if they are Base64-encoded or if they are referenced by a valid absolute URI. In case the HTML document you are loading includes images with relative paths, you can handle the event you have quoted - LoadImageFromUrl - mentioned in this article. The event args of the event have two properties - ImageInline and a Url. You can get the value of the src property in the HTML string from the Url property of the event args. Using it, you can determine which picture you would like to have inserted at that position and set the source of the ImageInline element. At the end, set the e.Handled property to True.

As for the umlauts, we were not able to reproduce the issue when importing and exporting the document. Please, verify that the characters appear correctly in test.html and that you are not doing some incorrect processing in the FileToByteArray method. You may have missed this, but HtmlFormatProvider has overloads of the Import method which take a string or a stream parameter which you could use if you find importing string/stream more convenient.

Regards,
Iva Toteva
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Tags
RichTextBox
Asked by
ITA
Top achievements
Rank 1
Answers by
Iva Toteva
Telerik team
Share this question
or