Extract Image From RadEditor's Document

2 posts, 0 answers
    SHSIOW avatar
    5 posts
    Member since:
    Jul 2014

    Posted 27 Aug Link to this post

    As per subject, I wonder if we can some how "extract" the image in our RadDocument.

    The background - I wanted user to be able to manipulate their photo via WPF apps but once it is uploaded to my website, I need those content to be translated into images so that I can save those images and refer to it via URL.

  2. Boyko
    Boyko avatar
    17 posts

    Posted 31 Aug Link to this post

    Hello SHSIOW,

    As I understand from your question, you need to extract the images from a RadDocument instance, loaded in RadRichTextBox. Please correct me if I am wrong.

    If this is the case, the following code extracts the images from the RadDocument and saves them to a specified location:   

    List<ImageInline> images = radRichTextBox.Document.EnumerateChildrenOfType<ImageInline>().ToList();
    string basePath = @"C:\SavedImages\{0}{1}{2}";
    for (int i = 0; i < images.Count(); i++)
        ImageInline image = images[i];
        using (FileStream fs = File.Create(string.Format(basePath, i, ".", image.Extension)))
            Stream imageStream = new MemoryStream(image.GetBytes());
            imageStream.Seek(0, SeekOrigin.Begin);

    Hope this helps.

    Telerik by Progress
    Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
  3. DevCraft R3 2016 release webinar banner
Back to Top