[Expand]General Information
[Collapse]WinForms Controls
 [Expand]What's Installed
 [Expand]Build an Application
 [Collapse]Controls and Libraries
  [Expand]Forms and User Controls
  [Expand]Messages, Notifications and Dialogs
  [Expand]Editors and Simple Controls
  [Expand]Ribbon, Bars and Menu
  [Expand]Application UI Manager
  [Expand]Docking Library
  [Expand]Data Grid
  [Expand]Vertical Grid
  [Expand]Property Grid
  [Expand]Pivot Grid
  [Expand]Tree List
  [Expand]Chart Control
  [Expand]Map Control
  [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
    Spell Checking
    Mail Merge
    Restrictions and Protection
    Syntax Highlighting
   [Expand]Visual Elements
    Keyboard Shortcuts
    HTML Tag Support
  [Expand]Spell Checker
  [Expand]Form Layout Managers
  [Expand]Navigation Controls
  [Expand]PDF Viewer
  [Expand]TreeMap Control
  [Expand]Sunburst Control
 [Expand]Common Features
  Get More Help
 [Expand]API Reference
[Expand]ASP.NET Controls and MVC Extensions
[Expand]ASP.NET Bootstrap Controls
[Expand]ASP.NET Core Bootstrap Controls
[Expand]WPF Controls
[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

In this document:

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 them to find and load the document. Refer to the How to: Create a Simple Word Processor with a Ribbon UI for details on how to provide a ribbon UI for the RichEditControl.

The DocumentSaveOptions.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 RichEditBehaviorOptions.CreateNew or RichEditBehaviorOptions.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


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

Expanded Format-Specific Import Options

Handle the RichEditControl.BeforeImport event to specify the format-specific import options (accessed by the RichEditControlOptionsBase.Import property) as shown in the code snippet below.


A complete code sample project is available at Import from HTML - How to specify encoding and external content location.

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:

Use the RichEditControlOptionsBase.DocumentCapabilities options to access the DocumentCapabilitiesOptions instance and restrict importing certain document elements (bookmarks, comments, fields, etc. ).


HYPERLINK fields represent hyperlinks in the RichEditControl. The DocumentCapabilitiesOptions.Fields 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 specify imported documents' 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 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.


A complete sample project is available at: How to use images when implementing the mail-merge functionality

This example demonstrates how to implement the IUriStreamProvider interface to create a custom data stream provider for the IUriProviderService service.

Expanded Save 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 How to: Create a Simple Word Processor with a Ribbon UI topic for information on how to provide a ribbon ui for the RichEditControl.

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


Set the RichEditBehaviorOptions.Save or RichEditBehaviorOptions.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 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 DocumentSaveOptions.CurrentFileName and DocumentSaveOptions.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 and 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.

Expanded Format-Specific Export Options

Handle the RichEditControl.BeforeExport event to specify the format-specific export options (accessed by the RichEditControlOptionsBase.Export property), as shown in the code snippet:


A complete sample project is available at How to save the text of a document range in different formats.

The table below lists the document formats the RichEditControl supports, and the API used to set format-specific export options:

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

Plain Text

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


A complete sample project is available at Exploring plain text exporter options.

The following code snippet illustrates how to use the PlainTextDocumentExporterOptions object properties to achieve the following:

  • Include document fields in the exported text
  • Enclose fields and their results in the specified symbols
  • Set character encoding

HTML Documents

You can specify how to process images in the exported HTML document. Handle the RichEditControl.BeforeExport event and set the HtmlDocumentExporterOptions.UriExportType and IExporterOptions.TargetUri properties 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.


A complete sample project is available at: How to save the text of a document range in different formats

Use the HtmlDocumentExporterOptions.EmbedImages option to store images in base-64 encoding. The HtmlDocumentExporterOptions.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 RtfDocumentExporterCompatibilityOptions.DuplicateObjectAsMetafile property 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 to reduce the size of the RTF file. Set the RtfDocumentExporterOptions.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.


A complete sample project is available at: The RichEditControl's common API

The following code loads the sample document, specifies export options using the PdfExportOptions settings and exports it to PDF. It invokes the default PDF viewer to display the resulting document.

The RichEditControl instance is passed to the BarItem.ItemClick event handler using the BarItem.Tag property.

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

Expanded See Also

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