Skip to content

Latest commit

 

History

History
81 lines (60 loc) · 3.34 KB

File metadata and controls

81 lines (60 loc) · 3.34 KB
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 Print
documentation ug
domainurl

Print PDF in Blazor PDF Viewer

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

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 %}

Print programmatically in Blazor PDF Viewer

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 %}

Key capabilities

View Sample in GitHub

See Also