DxRichEdit.PrintDocumentAsync(CancellationToken) Method
Renders the document’s markup in a blank browser tab and invokes the browser’s Print dialog.
Namespace: DevExpress.Blazor.RichEdit
Assembly: DevExpress.Blazor.RichEdit.v24.2.dll
NuGet Package: DevExpress.Blazor.RichEdit
Declaration
public ValueTask PrintDocumentAsync(
CancellationToken cancellationToken = default(CancellationToken)
)
Optional Parameters
Name | Type | Default | Description |
---|---|---|---|
cancellationToken | CancellationToken | null | An object that propagates a cancellation notification. |
Returns
Type | Description |
---|---|
ValueTask | A structure that stores an awaitable result of an asynchronous operation. |
Remarks
You should call the PrintDocumentAsync
method inside a user-generated event handler (such as a button click, a key press). Otherwise, a browser can block the Print dialog, which is a pop-up window, for security reasons.
Note that browsers track the delay between a user action and the method call that invokes the Print dialog. If this time interval exceeds a predefined value, the browser assumes that the two events are unrelated and blocks the popup. The maximum acceptable delay varies depending on the browser (usually it is a few seconds).
The following code snippet opens the Print dialog after a user clicks a custom Print Document button:
<DxButton Text="Print Document" Click=Print />
<DxRichEdit @ref="@richEdit"/>
@code {
DxRichEdit richEdit { get; set; }
async Task Print() {
await richEdit.PrintDocumentAsync();
}
}