Print in Blazor DOCX Editor

14 Aug 20261 minute to read

To print the document, use the PrintAsync method on the Document Editor instance.

Refer to the following example to print a document.

@using Syncfusion.Blazor.DocumentEditor

<button @onclick="OnPrint">Print</button>
<SfDocumentEditorContainer @ref="container" EnableToolbar="true"></SfDocumentEditorContainer>

@code {
    SfDocumentEditorContainer container;
    protected async void OnPrint(object args)
    {
        await container.DocumentEditor.PrintAsync();
    }
}

Improving print quality

The Document Editor provides an option to improve the print quality using PrintDevicePixelRatio in the Document Editor settings. The Document Editor uses a canvas approach to render content. Then, the canvas is converted to an image and processed for printing. Using the [PrintDevicePixelRatio] API, the image quality can be increased based on specific requirements.

The following example code illustrates how to improve the print quality in the Document Editor container.

<SfDocumentEditorContainer ID="cont" @ref="container" EnableToolbar="true" [DocumentEditorSettings]="settings" Height="590px">
</SfDocumentEditorContainer>

@code {
    SfDocumentEditorContainer container;
    DocumentEditorSettingsModel settings = new DocumentEditorSettingsModel() { PrintDevicePixelRatio = 2 };
}

NOTE

The default PrintDevicePixelRatio value is 1.