blazor-devexpress-dot-blazor-dot-richedit-dot-subdocument-dot-getrtfasync-x28-devexpress-dot-blazor-dot-richedit-dot-interval-system-dot-threading-dot-cancellationtoken-x29.md
Returns the specified interval’s content in Rich Text Format (RTF).
Namespace : DevExpress.Blazor.RichEdit
Assembly : DevExpress.Blazor.RichEdit.v25.2.dll
NuGet Package : DevExpress.Blazor.RichEdit
public ValueTask<string> GetRtfAsync(
Interval interval,
CancellationToken cancellationToken = default(CancellationToken)
)
| Name | Type | Description |
|---|---|---|
| interval | Interval |
The source RTF text interval.
|
| Name | Type | Default | Description |
|---|---|---|---|
| cancellationToken | CancellationToken | null |
An object that propagates a cancellation notification.
|
| Type | Description |
|---|---|
| ValueTask<String> |
A structure that stores an awaitable result of an asynchronous operation. The awaitable result is an RTF text string.
|
The following code snippet performs the following steps:
GetRtfAsync method to get the header’s RTF text.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);
Interval interval = await header.GetIntervalAsync();
string headerContent = await header.GetRtfAsync(interval);
await File.WriteAllTextAsync(pathRtf, headerContent);
}
await base.OnAfterRenderAsync(firstRender);
}
}
To get RTF text from an interval specified with the startPosition and length parameters, use the GetRtfAsync(Int32, Int32, CancellationToken) method.
See Also