Skip to main content

DevExpress v24.1 Update — Your Feedback Matters

Our What's New in v24.1 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

RichEditControl.HtmlText Property

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

Namespace: DevExpress.XtraRichEdit

Assembly: DevExpress.XtraRichEdit.v24.1.dll

NuGet Packages: DevExpress.Win.PivotGrid, DevExpress.Win.RichEdit, DevExpress.Win.TreeMap

#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 images embedded in the document body.

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

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

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


// Show the result in a browser window.
System.Diagnostics.Process.Start("test.html");

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.HtmlText when operating at the document level, or the SubDocument.GetHtmlText, to retrieve a document range in HTML format.

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

Note

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.

Check the HtmlText property value when the RichEditControl.DocumentLoaded event handler, i.e., when the document is fully loaded.

See Also