.NET Framework 4.5.2+
.NET Framework 4.5.2+
.NET Standard 2.0+

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.v20.2.Core.dll

Declaration

public bool AllowExtendingDocumentRange { get; set; }
Public Property AllowExtendingDocumentRange As Boolean

Property Value

Type Description
Boolean

true to permit extending the document range; otherwise false.

Examples

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.

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)
See Also