vcl-405570-expressricheditcontrol-print-and-import-export-document-import-and-export.md
TdxRichEditControl and TdxRichEditDocumentServer components allow you to import/export document content to/from a file or stream in a format of your choice: RTF, TXT, DOCX, HTML, and DOC.
Both TdxRichEditControl and TdxRichEditDocumentServer components implement similar API members designed for document import and export in supported formats.
Important
Ensure that support for all required document formats is enabled; otherwise, an exception occurs. Both components include dedicated import and export settings (for each supported document format).
Refer to the following topic section for details: Enable Support for Individual Document Formats.
TdxRichEditControl declares the following methods designed for content import and export:
LoadDocumentImports document content from a file or stream (in any supported format).LoadDocumentTemplateImports a document as a template from a file or stream (in any supported format).SaveDocumentExports document content to a file or stream (in any supported format).
TdxRichEditDocumentServer declares the following properties and methods designed for content import and export:
DocBytesSpecifies document content as a byte array (in the Microsoft Word® 97 – 2003 binary format).HtmlTextSpecifies document content as a string (in the HTML format).OpenXmlBytesSpecifies document content as a byte array (in the Office OpenXML format).RtfTextSpecifies document content (as an RTF string).TextSpecifies document content (as a plain text string).LoadDocument | LoadDocumentTemplate | SaveDocumentExport/import document content to/from a file or stream in any supported format.
DevExpress Rich Text components initially support a limited number of document formats to avoid excessive dependencies:
TdxRichEditControlHas predefined support only for TXT and RTF.TdxRichEditDocumentServerHas predefined support only for TXT.
To enable support for all available formats, add all required dependencies at design time or in code:
| Extension | Document Format | Format Value | Import/Export Settings | Support / Required Dependencies |
|---|---|---|---|---|
TXT/txt | Plain Text | PlainText | Options.Import.PlainText/Options.Export.PlainText | Built-in Support |
RTF/rtf | Rich Text Format | Rtf | Options.Import.Rtf/Options.Export.Rtf | dxRichEdit.Rtf (add only for TdxRichEditDocumentServer) |
DOC/doc | Microsoft Word® 97 – 2003 | Doc | Options.Import.Doc/Options.Export.Doc | dxRichEdit.Doc |
HTML/html | Hypertext Markup Language | Html | Options.Import.Html/Options.Export.Html | dxRichEdit.Html |
DOCX/docx | Office OpenXML | OpenXml | Options.Import.OpenXml/Options.Export.OpenXml | dxRichEdit.OpenXML |
At design time, you can right-click a TdxRichEditControl or TdxRichEditDocumentServer component, expand the Add Unit to Support menu item, and add all required dependencies.
TdxRichEditControl and TdxRichEditDocumentServer components have no HTML editor functionality because they do not work with HTML tags directly. HTML import routines interpret tags in a source document and build an internal document model according to the current import settings.
Important
HTML import and export routines support only a limited subset of the modern HTML standard – imported and exported documents may look different compared to corresponding source documents.
To see the Rich Edit import and export functionality in action, run the Word Processing RTF demo in the VCL Demo Center installed with compiled DevExpress demos. Click the Open or Save As button to open the corresponding dialog.
Tip
Compiled DevExpress demos ship with source code installed in the Public Documents folder (%Public%) for all users ( default ). You can find all project and source code files for the Rich Edit control demo in the following folder:
%Public%\Documents\DevExpress VCL Demos\MegaDemos\Product Demos\ExpressRichEditControl
See Also