The requested page is not available for the requested platform. You are viewing the content for .NET Framework 4.5.2+ platform.
.NET Framework 4.5.2+
.NET Framework 4.5.2+
.NET Standard 2.0+

Document.HtmlText Property

Gets or sets the document content as HTML text.

Namespace: DevExpress.XtraRichEdit.API.Native

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

Declaration

string HtmlText { get; set; }
Property HtmlText As String
string HtmlText { get; set; }
Property HtmlText As String

Property Value

Type Description
String

A string containing text of the document in HTML format.

Property Value

Type Description
String

A string containing text of the document 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.

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.
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.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.

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.

See Also