SubDocument.AddRtfAsync(String, CancellationToken) Method
In This Article
Inserts text in Rich Text Format (RTF) at the end of a sub-document.
Namespace: DevExpress.Blazor.RichEdit
Assembly: DevExpress.Blazor.RichEdit.v24.2.dll
NuGet Package: DevExpress.Blazor.RichEdit
#Declaration
C#
public ValueTask<Interval> AddRtfAsync(
string rtfText,
CancellationToken cancellationToken = default(CancellationToken)
)
#Parameters
Name | Type | Description |
---|---|---|
rtf |
String | The inserted RTF text string. |
#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 the inserted interval. |
#Remarks
The following code snippet inserts content of the C:\Temp\sample.rtf
file at the end of a Rich Text Editor’s sub-document.
Razor
<DxRichEdit @ref="@richEdit" />
@code {
DxRichEdit richEdit { get; set; }
string rtfContent { get; set; }
string path { get; set; } = @"C:\Temp\sample.rtf";
protected async override Task OnAfterRenderAsync(bool firstRender) {
if (firstRender) {
rtfContent = File.ReadAllText(path);
await richEdit.DocumentAPI.AddRtfAsync(rtfContent);
}
await base.OnAfterRenderAsync(firstRender);
}
}
To insert an RTF text string into the sub-document at the specified position, use the AddRtfAsync(Int32, String, CancellationToken) method.
See Also