Skip to content

Commit 5a0c825

Browse files
Merge pull request #3248 from syncfusion-content/1032245-printBlazor
1032245: Updated UG Documentation for Print in Blazor PDF Viewer
2 parents c6712e0 + 8b4b951 commit 5a0c825

8 files changed

Lines changed: 271 additions & 1 deletion

File tree

Document-Processing-toc.html

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1241,7 +1241,13 @@
12411241
<li><a href="/document-processing/pdf/pdf-viewer/blazor/organize-pages/events">Events</a></li>
12421242
</ul>
12431243
</li>
1244-
<li> <a href="/document-processing/pdf/pdf-viewer/blazor/print">Print</a></li>
1244+
<li><a href="/document-processing/pdf/pdf-viewer/blazor/print/overview">Print</a>
1245+
<ul>
1246+
<li><a href="/document-processing/pdf/pdf-viewer/blazor/print/print-modes">Print Modes</a></li>
1247+
<li><a href="/document-processing/pdf/pdf-viewer/blazor/print/enable-print-rotation">Print rotation</a></li>
1248+
<li><a href="/document-processing/pdf/pdf-viewer/blazor/print/events">Events</a></li>
1249+
</ul>
1250+
</li>
12451251
<li> <a href="/document-processing/pdf/pdf-viewer/blazor/document-security-overview">Document security</a>
12461252
<ul>
12471253
<li><a href="/document-processing/pdf/pdf-viewer/blazor/document-security/password-protected">Password Protected</a></li>
185 KB
Loading
176 KB
Loading
180 KB
Loading
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
---
2+
layout: post
3+
title: Enable Print Rotation in Blazor PDF Viewer | Syncfusion
4+
description: Learn how to enable print rotation for landscape documents in the Syncfusion Blazor PDF Viewer component.
5+
platform: document-processing
6+
control: Print
7+
documentation: ug
8+
domainurl: ##DomainURL##
9+
---
10+
11+
# Enable print rotation in Blazor PDF Viewer
12+
13+
The [EnablePrintRotation](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.SfPdfViewer.PdfViewerBase.html#Syncfusion_Blazor_SfPdfViewer_PdfViewerBase_EnablePrintRotation) property in the Blazor PDF Viewer controls how landscape pages are handled during printing. When enabled, the viewer automatically rotates landscape-oriented pages to match the printer’s paper orientation. This ensures that content fits properly on the page and avoids clipping.
14+
15+
By default, this property is set to **true**, meaning landscape pages are automatically adjusted for optimal printing. If set to **false**, pages retain their original orientation and are printed without any automatic rotation.
16+
17+
## When to use print rotation
18+
19+
Enable this feature when printing documents that include landscape pages and you want them to align with the printer’s paper orientation. This helps improve readability and ensures that content is not cut off during printing.
20+
21+
## Enabling print rotation
22+
23+
You can enable print rotation during the initialization of the PDF Viewer component by setting the `EnablePrintRotation` property to **true**.
24+
25+
26+
{% tabs %}
27+
{% highlight razor %}
28+
@using Syncfusion.Blazor.SfPdfViewer
29+
30+
<SfPdfViewer2 Height="100%"
31+
Width="100%"
32+
DocumentPath="@DocumentPath"
33+
EnablePrintRotation="true" />
34+
35+
@code{
36+
public string DocumentPath { get; set; } = "wwwroot/Data/PDF_Succinctly.pdf";
37+
}
38+
{% endhighlight %}
39+
{% endtabs %}
40+
41+
![Print rotation demo showing landscape pages rotated for printing](../images/print-rotate.gif)
42+
43+
[View Sample in GitHub](https://github.com/SyncfusionExamples/blazor-pdf-viewer-examples/tree/master/Print)
44+
45+
## See also
46+
47+
- [Overview](./overview)
48+
- [Print modes](./print-modes)
49+
- [Print events](./events)
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
---
2+
layout: post
3+
title: Print Events in Blazor PDF Viewer | Syncfusion
4+
description: Learn how to configure print events and track usage and implements workflows in the Syncfusion Blazor PDF Viewer component.
5+
platform: document-processing
6+
control: Print
7+
documentation: ug
8+
domainurl: ##DomainURL##
9+
---
10+
11+
# Print events in Blazor PDF Viewer
12+
13+
This page lists each event emitted by the Blazor PDF Viewer's print feature, the argument schema, and the minimal behavior notes needed for implementation.
14+
15+
## Events
16+
17+
| Name | Description |
18+
|--------------|-------------|
19+
| [PrintStart](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.SfPdfViewer.PdfViewerEvents.html#Syncfusion_Blazor_SfPdfViewer_PdfViewerEvents_PrintStart) | Raised when a print action begins. Use the event to log activity or cancel printing. |
20+
| [PrintEnd](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.SfPdfViewer.PdfViewerEvents.html#Syncfusion_Blazor_SfPdfViewer_PdfViewerEvents_PrintEnd) | Raised after a print action completes. Use the event to notify users or clean up resources. |
21+
22+
### PrintStart Event
23+
24+
The [PrintStart](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.SfPdfViewer.PdfViewerEvents.html#Syncfusion_Blazor_SfPdfViewer_PdfViewerEvents_PrintStart) event triggers when a print action begins.
25+
26+
#### Event arguments
27+
28+
See [PrintStartEventArgs](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.SfPdfViewer.PrintStartEventArgs.html) for details such as `FileName` and the `Cancel` option.
29+
30+
- If the [Cancel](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.SfPdfViewer.PrintStartEventArgs.html#Syncfusion_Blazor_SfPdfViewer_PrintStartEventArgs_Cancel) property is set to `true` in the `PrintStart` event handler, the print operation is canceled and the print dialog does not open.
31+
- By default, `Cancel` is `false`.
32+
33+
The following example illustrates how to handle the `PrintStart` event.
34+
35+
{% tabs %}
36+
{% highlight razor %}
37+
@using Syncfusion.Blazor.SfPdfViewer
38+
<SfPdfViewer2 DocumentPath="@DocumentPath" Height="100%" Width="100%">
39+
<PdfViewerEvents PrintStart="@PrintStart"></PdfViewerEvents>
40+
</SfPdfViewer2>
41+
@code{
42+
private string DocumentPath { get; set; } = "wwwroot/Data/PDF_Succintly.pdf";
43+
public async Task PrintStart(PrintStartEventArgs args)
44+
{
45+
Console.WriteLine($"Printed File Name: {args.FileName}");
46+
}
47+
}
48+
{% endhighlight %}
49+
{% endtabs %}
50+
51+
### PrintEnd Event
52+
53+
The [PrintEnd](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.SfPdfViewer.PdfViewerEvents.html#Syncfusion_Blazor_SfPdfViewer_PdfViewerEvents_PrintEnd) event triggers when a print action completes.
54+
55+
#### Event arguments
56+
57+
See [PrintEndEventArgs](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.SfPdfViewer.PrintEndEventArgs.html) for details such as `FileName`.
58+
59+
The following example illustrates how to handle the `PrintEnd` event.
60+
61+
{% tabs %}
62+
{% highlight razor %}
63+
@using Syncfusion.Blazor.SfPdfViewer
64+
<SfPdfViewer2 DocumentPath="@DocumentPath" Height="100%" Width="100%">
65+
<PdfViewerEvents PrintEnd="@PrintEnd"></PdfViewerEvents>
66+
</SfPdfViewer2>
67+
@code{
68+
private string DocumentPath { get; set; } = "wwwroot/Data/PDF_Succintly.pdf";
69+
public async Task PrintEnd(PrintEndEventArgs args)
70+
{
71+
Console.WriteLine($"Printed File Name: {args.FileName}");
72+
}
73+
}
74+
{% endhighlight %}
75+
{% endtabs %}
76+
77+
[View Sample in GitHub](https://github.com/SyncfusionExamples/blazor-pdf-viewer-examples/tree/master/Print)
78+
79+
## See also
80+
81+
- [Overview](./overview)
82+
- [Enable print rotation](./enable-print-rotation)
83+
- [Print modes](./print-modes)
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
---
2+
layout: post
3+
title: Print PDF in Blazor PDF Viewer | Syncfusion
4+
description: Enable and customize printing, configure print events, cancel print, and monitor printing in the Syncfusion Blazor PDF Viewer component.
5+
platform: document-processing
6+
control: Print
7+
documentation: ug
8+
domainurl: ##DomainURL##
9+
---
10+
11+
# Print PDF in Blazor PDF Viewer
12+
13+
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.
14+
15+
Select **Print** in the built-in toolbar to open the browser print dialog.
16+
17+
![Browser print dialog from PDF Viewer](../images/print.gif)
18+
19+
## Enable or Disable Print in Blazor PDF Viewer
20+
21+
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](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.SfPdfViewer.PdfViewerBase.html#Syncfusion_Blazor_SfPdfViewer_PdfViewerBase_EnablePrint) property (`true` enables printing; `false` disables it).
22+
23+
The following Blazor example renders the PDF Viewer with printing disabled.
24+
25+
{% tabs %}
26+
{% highlight razor %}
27+
@using Syncfusion.Blazor.SfPdfViewer
28+
29+
<SfPdfViewer2 Height="100%"
30+
Width="100%"
31+
DocumentPath="@DocumentPath"
32+
EnablePrint="false" />
33+
34+
@code{
35+
public string DocumentPath { get; set; } = "wwwroot/Data/PDF_Succinctly.pdf";
36+
}
37+
{% endhighlight %}
38+
{% endtabs %}
39+
40+
## Print programmatically in Blazor PDF Viewer
41+
42+
To start printing from code, call the [PrintAsync()](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.SfPdfViewer.SfPdfViewer.html#Syncfusion_Blazor_SfPdfViewer_SfPdfViewer_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.
43+
44+
{% tabs %}
45+
{% highlight razor %}
46+
@using Syncfusion.Blazor.SfPdfViewer
47+
@using Syncfusion.Blazor.Buttons
48+
49+
<SfButton OnClick="OnClick">Print</SfButton>
50+
<SfPdfViewer2 Width="100%"
51+
Height="100%"
52+
DocumentPath="@DocumentPath"
53+
@ref="@Viewer" />
54+
55+
@code{
56+
SfPdfViewer2 Viewer;
57+
public string DocumentPath { get; set; } = "wwwroot/data/PDF_Succinctly.pdf";
58+
59+
public async void OnClick(MouseEventArgs args)
60+
{
61+
await Viewer.PrintAsync();
62+
}
63+
}
64+
{% endhighlight %}
65+
{% endtabs %}
66+
67+
## Key capabilities
68+
69+
- Enable or disable printing with the [EnablePrint](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.SfPdfViewer.PdfViewerBase.html#Syncfusion_Blazor_SfPdfViewer_PdfViewerBase_EnablePrint) property
70+
- Start printing from UI (toolbar Print) or programmatically using [PrintAsync()](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.SfPdfViewer.SfPdfViewer.html#Syncfusion_Blazor_SfPdfViewer_SfPdfViewer_PrintAsync).
71+
- Auto‑rotate pages during print using [EnablePrintRotation](./enable-print-rotation)
72+
- Choose where printing happens with [PrintMode](./print-modes) (Default or NewWindow)
73+
- Track the life cycle with [PrintStart and PrintEnd events](./events)
74+
75+
[View Sample in GitHub](https://github.com/SyncfusionExamples/blazor-pdf-viewer-examples/tree/master/Print)
76+
77+
## See Also
78+
79+
- [Enable print rotation](./enable-print-rotation)
80+
- [Print modes](./print-modes)
81+
- [Print events](./events)
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
---
2+
layout: post
3+
title: Print Modes in Blazor PDF Viewer | Syncfusion
4+
description: Learn how to configure print modes for PDF Documents in the Syncfusion Blazor PDF Viewer component and more.
5+
platform: document-processing
6+
control: Print
7+
documentation: ug
8+
domainurl: ##DomainURL##
9+
---
10+
11+
# Print Modes in Blazor PDF Viewer
12+
13+
The [`PrintMode`](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.SfPdfViewer.PdfViewerBase.html#Syncfusion_Blazor_SfPdfViewer_PdfViewerBase_PrintMode) property determines how the print dialog is opened in the PDF Viewer. By default, it is set to PrintMode.Default, which prints the document from the same browser window.
14+
15+
## Available print modes
16+
17+
- [PrintMode.Default](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.SfPdfViewer.PrintMode.html): Prints the document from the current browser window.
18+
- [PrintMode.NewWindow](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.SfPdfViewer.PrintMode.html): Opens the print dialog in a new window or tab. This may be affected by browser pop-up blockers.
19+
20+
## Set print mode
21+
22+
You can configure the print mode during the initialization of the PDF Viewer component by setting the `PrintMode` property.
23+
24+
{% tabs %}
25+
{% highlight razor %}
26+
27+
@using Syncfusion.Blazor.SfPdfViewer
28+
29+
<SfPdfViewer2 Height="100%"
30+
Width="100%"
31+
DocumentPath="@DocumentPath"
32+
PrintMode="PrintMode.NewWindow" />
33+
34+
@code {
35+
public string DocumentPath { get; set; } = "wwwroot/Data/PDF_Succinctly.pdf";
36+
}
37+
38+
{% endhighlight %}
39+
{% endtabs %}
40+
41+
![Print in New Window](../images/print-newwindow.gif)
42+
43+
> **Note:** Ensure that browser pop-up blockers allow new windows or tabs when using `PrintMode.NewWindow`.
44+
45+
[View samples on GitHub](https://github.com/SyncfusionExamples/blazor-pdf-viewer-examples/tree/master/Print)
46+
47+
## See also
48+
49+
- [Overview](./overview)
50+
- [Enable print rotation](./enable-print-rotation)
51+
- [Print events](./events)

0 commit comments

Comments
 (0)