Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

SubDocument.GetRtfAsync(Int32, Int32, CancellationToken) Method

Returns the interval content in Rich Text Format (RTF). The startPosition and length parameters define the interval.

Namespace: DevExpress.Blazor.RichEdit

Assembly: DevExpress.Blazor.RichEdit.v24.2.dll

NuGet Package: DevExpress.Blazor.RichEdit

#Declaration

C#
public ValueTask<string> GetRtfAsync(
    int startPosition,
    int length,
    CancellationToken cancellationToken = default(CancellationToken)
)

#Parameters

Name Type Description
startPosition Int32

The interval’s start position.

length Int32

The interval’s length.

#Optional Parameters

Name Type Default Description
cancellationToken CancellationToken null

An object that propagates a cancellation notification.

#Returns

Type Description
ValueTask<String>

A structure that stores an awaitable result of an asynchronous operation. The awaitable result is an RTF text string.

#Remarks

The following code snippet performs the following steps:

  1. Calls the GetHeaderAsync(HeaderFooterType, Boolean, CancellationToken) method to access a sub-document’s header.
  2. Calls the GetRtfAsync method to get the first ten letters of the header text.
  3. Saves the obtained text to the header.rtf file.
Razor
<DxRichEdit @ref="@richEdit" />

@code {
    DxRichEdit richEdit { get; set; }
    string pathRtf { get; set; } = @"C:\Temp\header.rtf";

    protected async override Task OnAfterRenderAsync(bool firstRender) {
        if (firstRender) {
            Section section = await richEdit.DocumentAPI.Sections.GetAsync(0);
            SubDocument header = await section.GetHeaderAsync(HeaderFooterType.Primary, true);
            string headerContent = await header.GetRtfAsync(0,10);
            await File.WriteAllTextAsync(pathRtf, headerContent);
        }
        await base.OnAfterRenderAsync(firstRender);
    }
}

To get RTF text from an interval specified by an Interval object, use the GetRtfAsync(Interval, CancellationToken) method.

See Also