Skip to main content
.NET Framework 4.5.2+

Document.HtmlText Property

Gets or sets the document content as HTML text.

Namespace: DevExpress.XtraRichEdit.API.Native

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


string HtmlText { get; set; }

Property Value

Type Description

A string containing text of the document in HTML format.


The HtmlText property returns the HTML document with base64-encoded images embedded in the document body.

The code sample below uses the HtmlText property to export a document to HTML format.

Document document = richEditControl.Document;
document.LoadDocument("FirstLook.docx", DocumentFormat.OpenXml);

// Export to HTML
File.WriteAllText("test.html", document.HtmlText);

// Show the result in a browser window.

Use the SubDocument.GetHtmlText method to get the HTML source that contains image references.

Specify a custom IUriProvider to retain the original image URI when a document is loaded and then saved. Refer to the How to: Retain the Image URI in HTML Document article for a code sample.

Use the Document.LoadDocument method to load HTML content.

Use the Document.SaveDocument or RichEditControl.SaveDocumentAs method to save the document in HTML format. The HtmlText method constructs the HTML document with external content - e.g., images - replaced with the name placeholders numbered in consecutive order. That is, images are named img1.img etc.

Handle the BeforeExport event to specify HtmlDocumentExporterOptions and export the HTML document correctly.


If you set the HtmlText property to an HTML string, make sure that the string has the correct encoding.

Check the HTML Tag Support document for a list of supported HTML tags.

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the HtmlText property.


The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also