blazor-devexpress-dot-blazor-dot-richedit-dot-dxrichedit-dot-printdocumentasync-x28-system-dot-threading-dot-cancellationtoken-x29.md
The style-src: unsafe-inline CSP directive is not compatible with the LoadDocumentAsync method if called for documents using the HTML file format. Refer to the following help topic for additional information:
Content Security Policy (CSP).
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.v25.2.dll
NuGet Package : DevExpress.Blazor.RichEdit
public ValueTask PrintDocumentAsync(
CancellationToken cancellationToken = default(CancellationToken)
)
| Name | Type | Default | Description |
|---|---|---|---|
| cancellationToken | CancellationToken | null |
An object that propagates a cancellation notification.
|
| Type | Description |
|---|---|
| ValueTask |
A structure that stores an awaitable result of an asynchronous operation.
|
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();
}
}
See Also