| layout | post |
|---|---|
| title | Print PDF in Blazor PDF Viewer | Syncfusion |
| description | Enable and customize printing, configure print events, cancel print, and monitor printing in the Syncfusion Blazor PDF Viewer component. |
| platform | document-processing |
| control | |
| documentation | ug |
| domainurl |
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.
The Syncfusion Blazor PDF Viewer component lets users print a loaded PDF document through the built-in toolbar or programmatic calls. 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.
{% tabs %} {% highlight razor %} @using Syncfusion.Blazor.SfPdfViewer
@code{ public string DocumentPath { get; set; } = "wwwroot/Data/PDF_Succinctly.pdf"; } {% endhighlight %} {% endtabs %}
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; calling print before the document finishes loading can result in no output or an empty print dialog.
{% tabs %} {% highlight razor %} @using Syncfusion.Blazor.SfPdfViewer @using Syncfusion.Blazor.Buttons
Print <SfPdfViewer2 Width="100%" Height="100%" DocumentPath="@DocumentPath" @ref="@Viewer" />
@code{ SfPdfViewer2 Viewer; public string DocumentPath { get; set; } = "wwwroot/data/PDF_Succinctly.pdf";
public async void OnClick(MouseEventArgs args)
{
await Viewer.PrintAsync();
}
} {% endhighlight %} {% endtabs %}
- Enable or disable printing with the EnablePrint property
- Start printing from UI (toolbar Print) or programmatically using PrintAsync().
- Auto‑rotate pages during print using EnablePrintRotation
- Choose where printing happens with PrintMode (Default or NewWindow)
- Track the life cycle with PrintStart and PrintEnd events
