Back to Devexpress

DxRichEdit.PrintDocumentAsync(CancellationToken) Method

blazor-devexpress-dot-blazor-dot-richedit-dot-dxrichedit-dot-printdocumentasync-x28-system-dot-threading-dot-cancellationtoken-x29.md

latest2.6 KB
Original Source

DxRichEdit.PrintDocumentAsync(CancellationToken) Method

SECURITY-RELATED CONSIDERATIONS

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

Declaration

csharp
public ValueTask PrintDocumentAsync(
    CancellationToken cancellationToken = default(CancellationToken)
)

Optional Parameters

NameTypeDefaultDescription
cancellationTokenCancellationTokennull

An object that propagates a cancellation notification.

|

Returns

TypeDescription
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:

razor
<DxButton Text="Print Document" Click=Print />
<DxRichEdit @ref="@richEdit"/>

@code {
    DxRichEdit richEdit { get; set; }

    async Task Print() {
        await richEdit.PrintDocumentAsync();
    }
}

See Also

Document Management in Blazor Rich Text Editor

DxRichEdit Class

DxRichEdit Members

DevExpress.Blazor.RichEdit Namespace