SubDocument.GetText(DocumentRange) Method
Returns the plain text of the specified document range.
Namespace: DevExpress.XtraRichEdit.API.Native
Assembly: DevExpress.RichEdit.v20.2.Core.dll
Declaration
Parameters
Name | Type | Description |
---|---|---|
range | DocumentRange | A DocumentRange object, specifying the range in the document for which the plain text representation is obtained. |
Returns
Type | Description |
---|---|
String | A String value, containing the text of the specified range. |
Remarks
Use the GetText method to get a plain text of any part of the document. This method overload triggers export-related events as described in the following table:
Event | Description |
---|---|
RichEditControl.BeforeExport | Allows you to specify options for plain text export (defined by the PlainTextDocumentExporterOptions instance). |
RichEditControl.AfterExport | Does not occur. |
NOTE
If you operate with a selection range, the GetText method should be combined with a DocumentRange.BeginUpdateDocument - DocumentRange.EndUpdateDocument method pair. Otherwise, an incorrect document model might be selected, resulting in an exception "Error: specified document position or range belongs to other document or subdocument" being thrown.
Examples
NOTE
A complete sample project is available at https://github.com/DevExpress-Examples/word-processing-document-api-examples-t418535
DevExpress.XtraRichEdit.API.Native.Document document = server.Document;
document.LoadDocument("Documents\\Grimm.docx", DocumentFormat.OpenXml);
string plainText = document.GetText(document.Paragraphs[2].Range);
System.Windows.Forms.MessageBox.Show(plainText);