Print PDF in Blazor PDF Viewer

17 Jul 20262 minutes to read

The Blazor PDF Viewer includes built-in printing via the toolbar and APIs so users can control how documents are printed and monitor the process.

Select Print in the built-in toolbar to open the browser print dialog.

Browser print dialog from PDF Viewer

Enable or Disable Print in Blazor PDF Viewer

Control whether printing is available by setting the EnablePrint property (true enables printing; false disables it).

The following Blazor example renders the PDF Viewer with printing disabled.

@using Syncfusion.Blazor.SfPdfViewer

<SfPdfViewer2 Height="100%"
              Width="100%"
              DocumentPath="@DocumentPath"
              EnablePrint="false" />

@code{
    private string DocumentPath { get; set; } = "wwwroot/Data/PDF_Succinctly.pdf";
}

To start printing from code, call the PrintAsync() method after the document is fully loaded. This approach is useful when wiring up custom UI or initiating printing automatically.

If called before the document finishes loading, PrintAsync() produces no output or an empty print dialog.

@using Syncfusion.Blazor.SfPdfViewer
@using Syncfusion.Blazor.Buttons
@using Microsoft.AspNetCore.Components.Web

<SfButton OnClick="OnClick">Print</SfButton>
<SfPdfViewer2 Width="100%"
              Height="100%"
              DocumentPath="@DocumentPath"
              @ref="@Viewer" />

@code{
    private SfPdfViewer2? Viewer;
    private string DocumentPath { get; set; } = "wwwroot/Data/PDF_Succinctly.pdf";

    private async Task OnClick(MouseEventArgs args)
    {
        await Viewer.PrintAsync();
    }
}

Key capabilities

View Sample in GitHub

See also