TdxRichEditCustomDocumentServer.LoadDocument(TStream,TdxRichEditDocumentFormat) Method
Imports a document from a stream (in any supported format).
Declaration
function LoadDocument(AStream: TStream; ADocumentFormat: TdxRichEditDocumentFormat): Boolean; overload;
Parameters
Name | Type | Description |
---|---|---|
AStream | TStream | The source stream. |
ADocumentFormat | TdxRichEditDocumentFormat | The source document format. |
Returns
Type | Description |
---|---|
Boolean |
|
Remarks
Call the LoadDocument
function to import a document from a stream in any supported format. Imported content replaces the current document.
Related Properties and Events
A successful LoadDocument
call updates Options.DocumentSaveOptions.CurrentFileName and Options.DocumentSaveOptions.CurrentFormat property values and raises the OnDocumentLoaded event.
The OnDocumentClosing event occurs immediately before a document import operation if the current document contains unsaved changes.
Source Document Format Detection
Use the DocumentFormat
parameter to specify the source document format.
If you pass TdxRichEditDocumentFormat.Undefined as the DocumentFormat
parameter, the LoadDocument
procedure iterates through all supported formats to identify the best possible match for the source document.
Import Format Support
Support for all document formats, except for plain text, is initially disabled for the TdxRichEditDocumentServer component to avoid excessive dependencies. To enable support for 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 |
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 the TdxRichEditDocumentServer component, expand the Add Unit to Support menu item, and add all required dependencies.
Other Document Import/Export Options
You can also use the following API members to import/export document content in different supported[1] formats:
- DocBytes
- Specifies document content as a byte array (in the Microsoft Word® 97 – 2003 binary format).
- HtmlText
- Specifies document content as a string (in the HTML format).
- OpenXmlBytes
- Specifies document content as a byte array (in the Office OpenXML format).
- RtfText
- Specifies document content (as an RTF string).
- Text
- Specifies document content (as a plain text string).
- LoadDocument | LoadDocumentTemplate | SaveDocument
- Export/import document content to/from a file or stream in any supported format.