We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

How do I get the images out of a sfRichTextAdv control

I have a complex document created in the SfRichTextBoxAvd and I want to pull all the images from the document.

I added the image to the SfRichTextBoxAvd using the following code

 private async void InsertPictureButton_Click(object sender, RoutedEventArgs e)
            var fileOpenPicker = new FileOpenPicker();
            var stgFile = await fileOpenPicker.PickSingleFileAsync();
            if (stgFile != null)

I can get the ImageContainerAdv from the SfRichTextBoxAvd using the following code

 foreach (SectionAdv section in RichTextBoxAdv.Document.Sections)
                foreach (ParagraphAdv block in section.Blocks)
                    foreach (var inline in block.Inlines)
                        if (inline is ImageContainerAdv imageContainer)

imageContainer gives me the ImageSource and the ImageString (the latter is always empty).

However I cannot get the image content or any of the metadata associated with the image (file name and image mime type) from the imageContainer

My fallback is to convert the contents to html and then pull the base64 image from the img tags, however this feels like a kludge and does not get me the original file name.

1 Reply

VM Venkatesan Mani Syncfusion Team July 28, 2017 12:54 PM UTC

Hi Lee Davies,

Thank you for using Syncfusion products.

Our ImageContainerAdv does not preserve file name or mime type when inserting image using InsertPicture command. However we have provided an option to specify HTML export settings from our Essential Studio version v15.2.0.43. Using the event “ImageNodeVisitedEvent” of HtmlImportExportOptions instance, you will have the image data as stream. You can process the stream and specify the image string to be exported in HTML. Please find the release notes and API reference below.




We have prepared a sample using ImageNodeVisited event to process the stream, save it in local storage and specify the path to be exported in HTML Please find the same from the following link.

Sample link:

Try running the sample and let us know if this helps you.

Venkatesan M. 

Live Chat Icon For mobile
Up arrow icon