Import HTML - Images...

2 posts, 0 answers
  1. ITA
    ITA avatar
    384 posts
    Member since:
    Aug 2009

    Posted 26 Jun 2012 Link to this post


    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.
  2. Iva Toteva
    Iva Toteva avatar
    1319 posts

    Posted 29 Jun 2012 Link to this post

    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.

    Iva Toteva
    the Telerik team

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

Back to Top