.NET Framework 4.5.2+
.NET Framework 4.5.2+
.NET Standard 2.0+

SubDocument.GetHtmlText(DocumentRange, IUriProvider, HtmlDocumentExporterOptions) Method

Gets the text contained in the specified range in HTML format.

Namespace: DevExpress.XtraRichEdit.API.Native

Assembly: DevExpress.RichEdit.v21.1.Core.dll


string GetHtmlText(
    DocumentRange range,
    IUriProvider provider,
    HtmlDocumentExporterOptions options


Name Type Description
range DocumentRange

A DocumentRange object that is the text range in the document.

provider IUriProvider

A class that implements the IUriProvider interface and provides methods which return URI for images and CSS data.

options HtmlDocumentExporterOptions

A HtmlDocumentExporterOptions instance containing various options.


Type Description

A string of text in HTML format.


If the provider parameter is set to null, the method uses a default DataStringUriProvider that embeds images as base64-encoded data. In this situation the options parameter is disregarded.

If you operate with a selection, enclose the GetHtmlText method within a DocumentRange.BeginUpdateDocument - DocumentRange.EndUpdateDocument method pair. Otherwise, you may get an error “Specified document position or range belongs to other document or subdocument“.

To retrieve the section settings, make sure that the range contains the last section’s paragraph. Otherwise, the section settings are reset to the default.


This example demonstrates how to use the DocumentImage.Uri property to set the image’s src attribute when a document is saved in HTML format. You can switch on the HtmlDocumentExporterOptions.EmbedImages option to observe that the custom URI provider is idle for embedded images.

View Example: Retain the Original Image URI in an HTML Document

using DevExpress.Office.Services;
using DevExpress.XtraRichEdit.API.Native;
using DevExpress.XtraRichEdit.Export;
using System;
// ...
        private void richEditControl1_DocumentLoaded(object sender, EventArgs e)
            IUriProviderService service = richEditControl1.GetService<IUriProviderService>();
            if (service != null) {
                service.RegisterProvider(new CustomUriProvider());
        private void richEditControl1_ContentChanged(object sender, EventArgs e)

        private void ReloadHtml()
            HtmlDocumentExporterOptions exportOptions = new HtmlDocumentExporterOptions();
            exportOptions.EmbedImages = embedImagesCheck.Checked;
            string sText = richEditControl1.Document.GetHtmlText(richEditControl1.Document.Range, new CustomUriProvider(), exportOptions);
            memoEdit1.Text = sText;
See Also