Back to Devexpress

RichEditControl.HtmlText Property

wpf-devexpress-dot-xpf-dot-richedit-dot-richeditcontrol-e563caf8.md

latest3.5 KB
Original Source

RichEditControl.HtmlText Property

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

Namespace : DevExpress.Xpf.RichEdit

Assembly : DevExpress.Xpf.RichEdit.v25.2.dll

NuGet Package : DevExpress.Wpf.RichEdit

Declaration

csharp
[Bindable(true)]
[Browsable(false)]
public string HtmlText { get; set; }
vb
<Bindable(True)>
<Browsable(False)>
Public Property HtmlText As String

Property Value

TypeDescription
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 Export Document Images to HTML 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.

Assigning the HtmlText property value raises the RichEditControl.DocumentLoaded event. 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:

csharp
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");
vb
Dim htmlText As String = richEditControl1.HtmlText
  Using stream As New FileStream("result.html", FileMode.Create, FileAccess.Write)
    Using writer As New StreamWriter(stream)
      writer.Write(htmlText)
    End Using
  End Using

System.Diagnostics.Process.Start("result.html")

See Also

HtmlText

GetHtmlText

RichEditControl Class

RichEditControl Members

DevExpress.Xpf.RichEdit Namespace