[Expand]General Information
[Expand]WinForms Controls
[Expand]ASP.NET Controls and MVC Extensions
[Expand]ASP.NET Bootstrap Controls
[Expand]ASP.NET Core Bootstrap Controls
[Collapse]WPF Controls
 [Expand]What's Installed
 [Expand]Common Concepts
 [Expand]MVVM Framework
 [Collapse]Controls and Libraries
  [Expand]Data Grid
  [Expand]Ribbon, Bars and Menu
  [Expand]Charts Suite
  [Expand]Pivot Grid
  [Collapse]Rich Text Editor
   [Expand]Product Information
    Product Class Structure
    Supported Formats
   [Expand]Getting Started
   [Expand]RichEditControl Document
    Text Formatting
    Import and Export
   [Expand]Page Layout
    Mail Merge
    Restrictions and Protection
    Syntax Highlighting
   [Expand]Visual Elements
    HTML Tag Support
  [Expand]Tree List
  [Expand]Gauge Controls
  [Expand]Map Control
  [Expand]Layout Management
  [Expand]Windows Modern UI
  [Expand]Data Editors
  [Expand]Navigation Controls
  [Expand]Spell Checker
  [Expand]Property Grid
  [Expand]PDF Viewer
  [Expand]TreeMap Control
  [Expand]Gantt Control
  [Expand]Diagram Control
  [Expand]Windows and Utility Controls
   Dialogs, Notifications and Panels
  [Expand]Scheduler (legacy)
 [Expand]Scaffolding Wizard
  Redistribution and Deployment
  Get More Help
 [Expand]API Reference
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Office File API
[Expand]Report and Dashboard Server
[Expand]eXpressApp Framework
[Expand]eXpress Persistent Objects
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation
View this topic on docs.devexpress.com (Learn more)

Import and Export

Expanded Supported Formats

The RichEditControl supports the following document formats:

  • Plain Text;
  • RTF (Rich Text Format);
  • DOCX (MS Office Word 2007 -... format);
  • DOC (Microsoft Word 97-2003 format);
  • WordML (MS Office Word 2003 XML format);
  • OpenDocument (implemented by the OpenOffice.org office suite);
  • HTML;
  • MHTML (web page archive format);
  • EPUB (Electronic Publication);
  • PDF format (export only)

Expanded Load Documents in the User Interface

End-users can click the Open button on the File ribbon tab to invoke the Open dialog. This dialog allows end-users to find and load the document. Refer to the Lesson 1 - Create a Simple Rich Text Editor for details on how to provide a Ribbon UI for the RichEditControl.

The DXRichEditDocumentSaveOptions.CurrentFileName property returns the current document's file name (including the path and extension).


You can prohibit end-users from creating or loading documents. Set the DXRichEditBehaviorOptions.CreateNew or DXRichEditBehaviorOptions.Open property to DocumentCapability.Disabled to disable or hide the corresponding commands in the Ribbon UI and pop-up menu.

Expanded Load Documents in Code


Use the RichEditControl.DocumentSource property to bind the RichEditControl to a document source from XAML. The following data sources are supported:

  • System.IO.Stream;
  • System.Uri;
  • System.String (document content or document path);
  • System.IO.FileInfo;
  • System.Byte[];
  • RichEditDocumentSource.

You can use the DXBinding extension to call a method that returns a valid document source directly in XAML, as in the following code:

Changes made in the bound document are not saved automatically. Refer to the Lesson 7 - Bind the RichEditControl to a Document Source using the MVVM pattern topic for information on how to implement a custom command to save changes to the database.


Execute the LoadDocumentCommand to invoke the Open dialog and load the selected document.


The RichEditControl provides the following methods to import the document and specify its options:

Member Description
RichEditControl.LoadDocument Loads a document from a file or stream. The document format can be specified manually or detected automatically.
RichEditControl.LoadDocumentTemplate Loads a document from the specified file or stream so that it cannot be overwritten automatically.
Document.LoadDocument Loads a document from the specified file or stream. Its content determines the file format or specified manually.
SubDocument.InsertDocumentContent Inserts content from the specified range into the current document at the specified position.
SubDocument.AppendDocumentContent Appends content from the specified range to the end of the current document.

<<<<<<< articles/controls-and-libraries/rich-text-editor/import-and-export.md

Format-Specific Import Options


Expanded Format-Specific Import Options

articles/controls-and-libraries/rich-text-editor/import-and-export.md Handle the RichEditControl.BeforeImport event to specify the format-specific import options (accessed by the RichEditControl.ImportOptions property), as shown in the code snippet below.

The following example illustrates how to use the BeforeImport event to specify the location of the loaded HTML file's external content:

The table below lists the document formats the RichEditControl supports, and the API used to specify the necessary import options:

Format Import Options
Plain Text DXRichEditDocumentImportOptions.PlainTextOptions
Rich Text Format DXRichEditDocumentImportOptions.RtfOptions
DOCX DXRichEditDocumentImportOptions.OpenXmlOptions
DOC DXRichEditDocumentImportOptions.DocOptions
WordML DXRichEditDocumentImportOptions.WordMLOptions
MHT DXRichEditDocumentImportOptions.MhtOptions
HTML DXRichEditDocumentImportOptions.HtmlOptions

Use the RichEditControl.DocumentCapabilitiesOptions property to access the DXRichEditDocumentCapabilitiesOptions instance and restrict importing document elements (bookmarks, comments, fields, etc.).


HYPERLINK fields represent hyperlinks in the RichEditControl.TheDXRichEditDocumentCapabilitiesOptions.Fields property property disables showing/creating fields in the document. Set the RichEditControlCompatibility.LoadHyperlinkAsField property to false before calling the InitializeComponent method to enable using hyperlinks when fields are disabled.

You can use the Document.DefaultCharacterProperties or Document.DefaultParagraphProperties property to set every imported document's default character or paragraph formatting options.

HTML Documents

Loaded HTML documents are parsed and transformed into the internal document model. However, not every HTML tag can be converted into a corresponding document model element. Refer to the HTML Tag Support topic for a full list of supported tags.

During export to HTML format, the document model is parsed and transformed again. This means the resulting document is different from the original HTML document.

You can implement your IUriStreamProvider or IUriStreamService descendants and override the IUriStreamProvider.GetStream method to manage decoding external contents in an HTML file when an HTML document is loaded. When the RichEditControl needs to load data from a specific URI, it executes your method instead.

<<<<<<< articles/controls-and-libraries/rich-text-editor/import-and-export.md

Expanded Saving Documents in the User Interface

End-users can use the Save and Save As buttons on the File ribbon tab to save changes made to the current document or save it as a new file. Clicking the Save As button invokes the Save As dialog. This dialog allows end users to specify the document's location, name, and format. Refer to the Lesson 1 - Create a Simple Rich Text Editor for details on how to provide a Ribbon UI for the RichEditControl.



Expanded Save Documents in the User Interface

End-users can save changes made in the current document or save it as a new file using Save and Save As buttons on the File ribbon tab. Clicking the Save As button invokes the Save As dialog, which allows end-users to specify the document's location, name, and format. Refer to the Lesson 1 - Create a Simple Rich Text Editor for details on how to provide a Ribbon UI for the RichEditControl.


The DXRichEditDocumentSaveOptions.CurrentFileName property retruns the current document's fiel name (including the path and extension).


Set the DXRichEditBehaviorOptions.Save or DXRichEditBehaviorOptions.SaveAs property to DocumentCapability.Disabled to prohibit end-users from saving documents.

Expanded Save Documents in Code


Execute the SaveDocumentCommand to save changes to the current document. If the document is saved for the first time, it invokes the Save As dialog. Otherwise, this command saves the document with the name and format the DXRichEditDocumentSaveOptions.CurrentFileName and DXRichEditDocumentSaveOptions.CurrentFormat properties specify.

Executing the SaveDocumentAsCommand command always invokes the Save As dialog that saves a document as a file with the given name and format.


Use the following methods to save a document manually:


The SaveDocumentCommand or SaveDocumentAsCommand execution sets the RichEditControl.Modified property to false. The RichEditControl.SaveDocument, RichEditControl.SaveDocumentAs or Document.SaveDocument method call does not automatically change the Modified property value.

<<<<<<< articles/controls-and-libraries/rich-text-editor/import-and-export.md

Format-Specific Export Options


Expanded Format-Specific Export Options

articles/controls-and-libraries/rich-text-editor/import-and-export.md Handle the RichEditControl.BeforeExport event to specify the format-specific export options (accessed by the RichEditControl.ExportOptions property), as shown in the code snippet:

Use the API from the table below to set the corresponding export options:

Format Export Options
Plain Text DXRichEditDocumentExportOptions.PlainTextOptions
Rich Text Format DXRichEditDocumentExportOptions.RtfOptions
MS Word 2007 (OpenXML) DXRichEditDocumentExportOptions.OpenXmlOptions
DOC DXRichEditDocumentExportOptions.DocOptions
WordML DXRichEditDocumentExportOptions.WordMLOptions
HTML DXRichEditDocumentExportOptions.HtmlOptions
MHT DXRichEditDocumentExportOptions.MhtOptions
PDF PdfExportOptions

Use the RichEditControl.DocumentSaveOptions property to define the saved document's name and format.

Plain Text

Set the DXRichEditPlainTextDocumentExporterOptions.ExportHiddenText to <b>true</b> to include fields in the exported text. Specify DXRichEditPlainTextDocumentExporterOptions.FieldCodeStartMarker, DXRichEditPlainTextDocumentExporterOptions.FieldCodeEndMarker and PlainTextDocumentExporterOptions.FieldResultEndMarker properties to define field code and field result borders.

HTML Documents

You can specify how to process images in the exported HTML document. Handle the RichEditControl.BeforeExport event and set the DXRichEditHtmlDocumentExporterOptions.UriExportType and IExporterOptions.TargetUri to define a path for external files. You can implement your class with the IUriProvider interface and override the IUriProvider.CreateImageUri and IUriProvider.CreateCssUri methods. This class can be used instead of the default URI provider. Register a new service to save CSS files and provide unique names for image files, as shown in the code snippet below.

Use the DXRichEditHtmlDocumentExporterOptions.EmbedImages option to store images in base-64 encoding. The DXRichEditHtmlDocumentExporterOptions.TabMarker property allows you to substitute Tab (0x09) characters with any symbol combination in HTML output.

Specify the corresponding paragraph's Paragraph.OutlineLevel property to mark the text in HTML output with H1 - H6 tags. Paragraphs with outline levels higher than 6 are exported as text enclosed in a P tag.

RTF Documents

Some text editing applications cannot process the native picture format but can display a Windows Metafile. Use the DXRichEditRtfDocumentExporterCompatibilityOptions.DuplicateObjectAsMetafile to store an exported document's inline images in the native format and as a Windows Metafile.

You can delete unused styles from the Document.CharacterStyles, Document.ParagraphStyles and Document.TableStyles style collections before exporting to reduce the size of the RTF file. Set the DXRichEditRtfDocumentExporterOptions.ExportTheme property to false to exclude color theme information from the file.

PDF Documents

Call the RichEditControl.ExportToPdf method to process the PDF export. Use the PdfExportOptions class properties to specify advanced export settings, as demonstrated below.

Expanded Get or Set Document Content

Use one of the following properties to get or set the document content to a specific format:


Use the SubDocument's Get... methods to retrieve and format a part of the document. Refer to the Positions and Ranges topic for details.

Expanded See Also

Is this topic helpful?​​​​​​​