SubDocument.GetRtfAsync(Int32, Int32, CancellationToken) Method
In This Article
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 |
---|---|---|
start |
Int32 | The interval’s start position. |
length | Int32 | The interval’s length. |
#Optional Parameters
Name | Type | Default | Description |
---|---|---|---|
cancellation |
Cancellation |
null | An object that propagates a cancellation notification. |
#Returns
Type | Description |
---|---|
Value |
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:
- Calls the GetHeaderAsync(HeaderFooterType, Boolean, CancellationToken) method to access a sub-document’s header.
- Calls the
GetRtfAsync
method to get the first ten letters of the header text. - 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