TextFragmentOptions.AllowExtendingDocumentRange Property
Specifies whether or not a document range may be extended to include the entire field instead of only part of a field.
Namespace: DevExpress.XtraRichEdit.API.Native.Implementation
Assembly: DevExpress.RichEdit.v19.1.Core.dll
Declaration
Property Value
Type | Description |
---|---|
Boolean | true to permit extending the document range; otherwise false. |
Example
This code snippet finds the first table of contents which is built upon Heading styles using the TOC field and converts it to plain text paragraph by paragraph. The SubDocument.GetText method overload is used for this purpose. It allows you to set the TextFragmentOptions.AllowExtendingDocumentRange
option to false to not include the entire TOC when exporting the first paragraph.
Note
A complete sample project is available at https://github.com/DevExpress-Examples/winforms-richedit-document-api-e5219
document.LoadDocument("SampleTOC.docx", DocumentFormat.OpenXml)
Dim plainText As String = String.Empty
For Each item As Field In document.Fields
Dim fieldCode As String = document.GetText(item.CodeRange)
Dim fieldParts() As String = fieldCode.Split(" "c)
If fieldParts(0).Trim() = "TOC" AndAlso fieldParts(1).Trim() = "\h" Then
Dim options As New DevExpress.XtraRichEdit.API.Native.Implementation.TextFragmentOptions()
options.AllowExtendingDocumentRange = False
For Each par As Paragraph In document.Paragraphs.Get(item.ResultRange)
plainText &= document.GetText(par.Range, options)
plainText &= Environment.NewLine
Next par
End If
Next item
DevExpress.XtraEditors.XtraMessageBox.SmartTextWrap = False
DevExpress.XtraEditors.XtraMessageBox.Show(plainText)
Related GitHub Examples
The following code snippet (auto-collected from DevExpress Examples) contains a reference to the AllowExtendingDocumentRange property.
Note
The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.