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.GetIntervalAsync(CancellationToken) Method

Returns a sub-document’s interval.

Namespace: DevExpress.Blazor.RichEdit

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

NuGet Package: DevExpress.Blazor.RichEdit

#Declaration

C#
public ValueTask<Interval> GetIntervalAsync(
    CancellationToken cancellationToken = default(CancellationToken)
)

#Optional Parameters

Name Type Default Description
cancellationToken CancellationToken null

An object that propagates a cancellation notification.

#Returns

Type Description
ValueTask<Interval>

A structure that stores an awaitable result of an asynchronous operation. The awaitable result is the returned interval.

#Remarks

The following code snippet performs the following steps:

  1. Calls the GetIntervalAsync method to access a sub-document’s interval. This interval corresponds to the document header.
  2. Passes the returned interval to the GetRtfAsync(Interval, CancellationToken) method to get the header’s RTF 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);
            Interval interval = await header.GetIntervalAsync();
            string headerContent = await header.GetRtfAsync(interval);
            await File.WriteAllTextAsync(pathRtf, headerContent);
        }
        await base.OnAfterRenderAsync(firstRender);
    }
}
See Also