Skip to main content
All docs
V25.1
  • 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.v25.1.dll

    NuGet Package: DevExpress.Blazor.RichEdit

    Declaration

    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.
    <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