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

RichEditControl.HtmlText Property

Gets or sets the control’s content as HTML text.

Namespace: DevExpress.Xpf.RichEdit

Assembly: DevExpress.Xpf.RichEdit.v19.1.dll

Declaration

[Bindable(true)]
[Browsable(false)]
public string HtmlText { get; set; }

Property Value

Type Description
String

A string containing text in HTML format.

Remarks

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

Use the SubDocument.GetHtmlText method to get HTML source that contains image references.
Specify a custom IUriProvider to retain the original image URI when a document is loaded and then saved using the OfficeImage.Uri property. Refer to the How to: Retain the Image URI in an HTML Document topic for a code example.

Use the Document.HtmlText to operate at the document level. The SubDocument.GetHtmlText method retrieves a document range in HTML format.

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

When the document model is built and the loaded document is valid, the RichEditControl.DocumentLoaded event raises. Check the HtmlText property value in the RichEditControl.DocumentLoaded event handler, i.e., when the document is fully loaded.

The code sample below retrieves and saves the document content in HTML format:

string htmlText = richEditControl1.HtmlText;
  using (FileStream stream = new FileStream("result.html",
   FileMode.Create, FileAccess.Write))
  {
      using (StreamWriter writer = new StreamWriter(stream))
      {
          writer.Write(htmlText);
      }
  }

System.Diagnostics.Process.Start("result.html");
See Also