Skip to main content
A newer version of this page is available. .

Document.HtmlText Property

Gets or sets the document content as HTML text.

Namespace: DevExpress.XtraRichEdit.API.Native

Assembly: DevExpress.RichEdit.v18.2.Core.dll

Declaration

string HtmlText { get; set; }

Property Value

Type Description
String

A string containing text of the document in HTML format.

Remarks

The HtmlText property returns the HTML document with images which are base64-encoded and embedded in the document body. This is the default behavior.

To get the HTML source that contains image references, use the SubDocument.GetHtmlText method. You should specify a custom UriProvider that provides a URI for each image. For example, it allows you to retain the original image URI when a document is loaded and then saved, using the OfficeImage.Uri property. See the How to: Retain the Image URI in HTML Document article for an use example .

Use the Document.HtmlText when operating at the document level, or the SubDocument.GetHtmlText, to retrieve a document range in HTML format.

Use the Document.SaveDocument or the RichEditControl.SaveDocumentAs methods 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.

To load HTML content into RichEditControl, use the Document.LoadDocument method. This is the most versatile method and enables you to load HTML from a file or a stream.

However, certain tasks may require assigning an HTML string to the HtmlText. Note that you should provide a string with correct encoding, because in this case RichEditControl does not use autodetect feature and ignores the charset meta tag when processing HTML contained in the string value of the HtmlText property.

For a list of supported HTML tags see the HTML Tag Support document.

See Also