[Expand]General Information
[Expand]WinForms Controls
[Expand]ASP.NET Controls and MVC Extensions
[Expand]ASP.NET Bootstrap Controls
[Expand]ASP.NET Core Bootstrap Controls
[Collapse]WPF Controls
 [Expand]What's Installed
 [Expand].NET Core 3 Support
 [Expand]Common Concepts
 [Expand]MVVM Framework
 [Collapse]Controls and Libraries
  [Expand]Data Grid
  [Expand]Ribbon, Bars and Menu
  [Expand]Charts Suite
  [Expand]Pivot Grid
  [Collapse]Rich Text Editor
   [Expand]Product Information
    Product Class Structure
    Supported Formats
   [Expand]Getting Started
   [Expand]RichEditControl Document
    Text Formatting
    Import and Export
   [Expand]Page Layout
    Track Changes
    Mail Merge
    Restrictions and Protection
   [Expand]Visual Elements
    HTML Tag Support
    [Expand]UI Customization
    [Expand]Text Boxes
     Spell Check
      How to: Retain the Image URI in an HTML Document
      How to: Save a Document as a Series of Images
      How to: Send the Mail-Merge Document as an E-Mail
  [Expand]Tree List
  [Expand]Gauge Controls
  [Expand]Map Control
  [Expand]Layout Management
  [Expand]Windows Modern UI
  [Expand]Data Editors
  [Expand]Navigation Controls
  [Expand]Spell Checker
  [Expand]Property Grid
  [Expand]PDF Viewer
  [Expand]TreeMap Control
  [Expand]Gantt Control
  [Expand]Diagram Control
  [Expand]Windows and Utility Controls
   Dialogs, Notifications and Panels
  [Expand]Scheduler (legacy)
 [Expand]Scaffolding Wizard
  Redistribution and Deployment
  Get More Help
 [Expand]API Reference
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Office File API
[Expand]Report and Dashboard Server
[Expand]eXpressApp Framework
[Expand]eXpress Persistent Objects
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation
View this topic on docs.devexpress.com (Learn more)

How to: Retain the Image URI in an HTML Document

This example provides more details on HTML export and describes how to store the original image URI in the exported document.

When RichEditControl loads an HTML document, it imports the document and converts it into a native document model, and then converts the native document to the resulting document's format when it is saved.

The list below describes the two options to images on export to HTML.

  • Embed images into the resulting file as base64-encoded data.

  • Save images as separate files.
    The images are named using the "image" word followed by its sequential number in a file. Images are saved to the folder with a name that combines the file name, an underscore and the "files" word. For example, the first png image in the resulting Test.html file is saved to Test_files\image0.png.

Expanded Implement a Custom URI Provider

The HTML exporter uses a URI provider instance to obtain each image's URI string. There are two built-in URI providers - the FileBasedUriProvider which provides image file names, and the DataStringUriProvider that constructs a tag for embedded base64 data. The built-in URI provider service (a service that implements the IUriProviderService interface) is used to obtain a provider instance.

You can implement a custom URI provider to specify a custom location for each image when the document is saved to HTML format. To accomplish this, create an IUriProvider descendant and register it in RichEditControl services.


The SubDocument.GetHtmlText method allows you to specify a custom URI provider as the method's parameter, bypassing the URI provider service and the RichEditControl.ExportOptions.HtmlOptions.EmbedImages option.

Each image in the RichEditControl has the OfficeImage.Uri property that is the original image URI. To save an original image URI to the exported HTML document, our custom UriProvider returns the OfficeImage.Uri value.

Expanded Export the Result

The following table shows the different methods used to embed images and export the document to HTML format:

Export Result
RichEditControl.HtmlText property Images are contained in the resulting file as base64-encoded data.
SubDocument.GetHtmlText method The HtmlDocumentExporterOptions parameter allows you to specify embedded or standalone images by setting the HtmlDocumentExporterOptions.EmbedImages property.
RichEditControl.SaveDocument or RichEditControl.SaveDocumentAs methods The DXRichEditHtmlDocumentExporterOptions.EmbedImages property, accessible using the RichEditControl.ExportOptions.HtmlOptions.EmbedImages notation, determines whether images are embedded or saved as separate files. Specify this property in the RichEditControl.BeforeExport event handler.

The code sample below specifies the HtmlDocumentExporterOptions properties and retrieves the document content in HTML format.

Is this topic helpful?​​​​​​​