Skip to content

Commit 2e3c69b

Browse files
1032245: Updated UG Documentation for Print in Blazor PDF Viewer
1 parent 6ab0f8c commit 2e3c69b

9 files changed

Lines changed: 372 additions & 1 deletion

File tree

Document-Processing-toc.html

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1236,7 +1236,14 @@
12361236
<li><a href="/document-processing/pdf/pdf-viewer/blazor/organize-pages/events">Events</a></li>
12371237
</ul>
12381238
</li>
1239-
<li> <a href="/document-processing/pdf/pdf-viewer/blazor/print">Print</a></li>
1239+
<li><a href="/document-processing/pdf/pdf-viewer/blazor/print/overview">Print</a>
1240+
<ul>
1241+
<li><a href="/document-processing/pdf/pdf-viewer/blazor/print/print-modes">Print Modes</a></li>
1242+
<li><a href="/document-processing/pdf/pdf-viewer/blazor/print/print-quality">Print Quality</a></li>
1243+
<li><a href="/document-processing/pdf/pdf-viewer/blazor/print/enable-print-rotation">Print rotation</a></li>
1244+
<li><a href="/document-processing/pdf/pdf-viewer/blazor/print/events">Events</a></li>
1245+
</ul>
1246+
</li>
12401247
<li> <a href="/document-processing/pdf/pdf-viewer/blazor/document-security-overview">Document security</a>
12411248
<ul>
12421249
<li><a href="/document-processing/pdf/pdf-viewer/blazor/document-security/password-protected">Password Protected</a></li>
487 KB
Loading
389 KB
Loading
422 KB
Loading
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
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+
This guide shows how to enable automatic rotation of landscape pages during printing so they match the paper orientation and reduce clipping. Use [EnablePrintRotation](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.SfPdfViewer.PdfViewerBase.html#Syncfusion_Blazor_SfPdfViewer_PdfViewerBase_EnablePrintRotation) when printing documents that include landscape pages and you want them rotated to match the printer paper orientation.
14+
15+
## Prerequisites
16+
17+
- A Blazor app with the Syncfusion PDF Viewer component integrated.
18+
19+
## Steps to enable print rotation
20+
21+
1. Configure the [SfPdfViewer](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.SfPdfViewer.SfPdfViewer.html) component in your Blazor application.
22+
2. Set [EnablePrintRotation](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.SfPdfViewer.PdfViewerBase.html#Syncfusion_Blazor_SfPdfViewer_PdfViewerBase_EnablePrintRotation)="true" in the PDF Viewer during initialization.
23+
24+
## Example
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+
## Troubleshooting
46+
47+
- If you need to preserve original page orientation for archival printing, set [EnablePrintRotation](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.SfPdfViewer.PdfViewerBase.html#Syncfusion_Blazor_SfPdfViewer_PdfViewerBase_EnablePrintRotation)="false".
48+
- Confirm that the PDF Viewer component is properly configured with the correct resource URL.
49+
50+
## See also
51+
52+
- [Overview](./overview)
53+
- [Print quality](./print-quality)
54+
- [Print modes](./print-modes)
55+
- [Print events](./events)
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
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+
- [Print quality](./print-quality)
83+
- [Enable print rotation](./enable-print-rotation)
84+
- [Print modes](./print-modes)
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
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+
- Control output quality with the [PrintScaleFactor](./print-quality) property (0.5–5)
72+
- Auto‑rotate pages during print using [EnablePrintRotation](./enable-print-rotation)
73+
- Choose where printing happens with [PrintMode](./print-modes) (Default or NewWindow)
74+
- Track the life cycle with [PrintStart and PrintEnd events](./events)
75+
76+
## Troubleshooting
77+
78+
- Ensure the resource URL value matches the deployed `ej2-pdfviewer-lib` version.
79+
- Calling [PrintAsync()](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.SfPdfViewer.SfPdfViewer.html#Syncfusion_Blazor_SfPdfViewer_SfPdfViewer_PrintAsync) launches the browser print dialog; behavior varies by browser and may be affected by popup blockers or browser settings.
80+
81+
[View Sample in GitHub](https://github.com/SyncfusionExamples/blazor-pdf-viewer-examples/tree/master/Print)
82+
83+
## See Also
84+
85+
- [Print quality](./print-quality)
86+
- [Enable print rotation](./enable-print-rotation)
87+
- [Print modes](./print-modes)
88+
- [Print events](./events)
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
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 the Blazor PDF Viewer
12+
13+
This guide shows how to set the PDF Viewer [`PrintMode`](https://ej2.syncfusion.com/blazor/documentation/api/pdfviewer/pdfviewer#printmode) so PDFs print from the current window or from a new window/tab.
14+
15+
## Prerequisites
16+
17+
- A Blazor app with the Syncfusion PDF Viewer component integrated.
18+
19+
## Steps to set print mode
20+
21+
**Step 1:** Decide which [PrintMode](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.SfPdfViewer.PdfViewerBase.html#Syncfusion_Blazor_SfPdfViewer_PdfViewerBase_PrintMode) you need:
22+
- `PrintMode.Default` — print from the same browser window.
23+
- `PrintMode.NewWindow` — print from a new window or tab (may be blocked by pop-up blockers).
24+
25+
**Step 2:** Set [PrintMode](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.SfPdfViewer.PdfViewerBase.html#Syncfusion_Blazor_SfPdfViewer_PdfViewerBase_PrintMode) during viewer initialization (recommended):
26+
27+
{% tabs %}
28+
{% highlight razor %}
29+
@using Syncfusion.Blazor.SfPdfViewer
30+
31+
<SfPdfViewer2 Height="100%"
32+
Width="100%"
33+
DocumentPath="@DocumentPath"
34+
PrintMode="PrintMode.NewWindow" />
35+
36+
@code{
37+
public string DocumentPath { get; set; } = "wwwroot/Data/PDF_Succinctly.pdf";
38+
}
39+
{% endhighlight %}
40+
{% endtabs %}
41+
42+
![Print in New Window](../images/print-newwindow.gif)
43+
44+
**Step 3:** Print mode can also be changed at runtime after the viewer is created:
45+
46+
{% tabs %}
47+
{% highlight razor %}
48+
// switch to NewWindow at runtime
49+
pdfViewerRef.PrintMode = "NewWindow";
50+
{% endhighlight %}
51+
{% endtabs %}
52+
53+
## Quick reference
54+
55+
- `PrintMode.Default`: Print from the same window (default).
56+
- `PrintMode.NewWindow`: Print from a new window or tab.
57+
58+
N> Browser pop-up blockers must allow new windows or tabs when using `PrintMode = PrintMode.NewWindow`.
59+
60+
[View samples on GitHub](https://github.com/SyncfusionExamples/blazor-pdf-viewer-examples/tree/master/Print)
61+
62+
## See also
63+
64+
- [Overview](./overview)
65+
- [Print quality](./print-quality)
66+
- [Enable print rotation](./enable-print-rotation)
67+
- [Print events](./events)
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
---
2+
layout: post
3+
title: Customize Print Quality in Blazor PDF Viewer | Syncfusion
4+
description: Learn how to customize print quality for PDF Documents in the Syncfusion Blazor PDF Viewer component.
5+
platform: document-processing
6+
control: Print
7+
documentation: ug
8+
domainurl: ##DomainURL##
9+
---
10+
11+
# Customize Print Quality in Blazor PDF Viewer
12+
13+
This article shows a concise, task-oriented workflow to set and verify print quality for documents rendered by the Blazor PDF Viewer by using the [PrintScaleFactor](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.SfPdfViewer.PdfViewerBase.html#Syncfusion_Blazor_SfPdfViewer_PdfViewerBase_PrintScaleFactor) property.
14+
15+
**Goal:** Set a suitable [PrintScaleFactor](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.SfPdfViewer.PdfViewerBase.html#Syncfusion_Blazor_SfPdfViewer_PdfViewerBase_PrintScaleFactor) to improve printed output sharpness while balancing performance and memory use.
16+
17+
## Steps
18+
19+
### 1. Choose a target print quality.
20+
21+
- Valid [PrintScaleFactor](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.SfPdfViewer.PdfViewerBase.html#Syncfusion_Blazor_SfPdfViewer_PdfViewerBase_PrintScaleFactor) values: **0.5 – 5**. Higher values increase image sharpness and resource use.
22+
- Default value: **1**.
23+
24+
### 2. Set `PrintScaleFactor` during initialization
25+
26+
It is recommended that you set the [PrintScaleFactor](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.SfPdfViewer.PdfViewerBase.html#Syncfusion_Blazor_SfPdfViewer_PdfViewerBase_PrintScaleFactor) in the viewer options during initialization.
27+
28+
{% tabs %}
29+
{% highlight razor %}
30+
@using Syncfusion.Blazor.SfPdfViewer
31+
32+
<SfPdfViewer2 Height="100%"
33+
Width="100%"
34+
DocumentPath="@DocumentPath"
35+
PrintScaleFactor="2" />
36+
37+
@code{
38+
public string DocumentPath { get; set; } = "wwwroot/Data/PDF_Succinctly.pdf";
39+
}
40+
{% endhighlight %}
41+
{% endtabs %}
42+
43+
### 3. Set `PrintScaleFactor` after instantiation
44+
45+
As an alternative option, the [PrintScaleFactor](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.SfPdfViewer.PdfViewerBase.html#Syncfusion_Blazor_SfPdfViewer_PdfViewerBase_PrintScaleFactor) can be dynamically changed during runtime
46+
47+
{% tabs %}
48+
{% highlight razor %}
49+
// Update PrintScaleFactor at runtime
50+
pdfViewerRef.PrintScaleFactor = 2; // increase print resolution for upcoming prints
51+
{% endhighlight %}
52+
{% endtabs %}
53+
54+
### 4. Verify output
55+
56+
Use browser Print Preview or produce a printed/PDF copy to confirm sharpness and acceptable render time.
57+
58+
## Notes
59+
60+
- Values outside the supported range **0.5 – 5** will be ignored and fall back to the default (`1`).
61+
- Increasing [PrintScaleFactor](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.SfPdfViewer.PdfViewerBase.html#Syncfusion_Blazor_SfPdfViewer_PdfViewerBase_PrintScaleFactor) raises CPU, memory, and rendering time requirements. Test on target machines and documents before setting a higher factor.
62+
63+
[View samples on GitHub](https://github.com/SyncfusionExamples/blazor-pdf-viewer-examples/tree/master/Print)
64+
65+
## See Also
66+
67+
- [Overview](./overview)
68+
- [Enable print rotation](./enable-print-rotation)
69+
- [Print modes](./print-modes)
70+
- [Print events](./events)

0 commit comments

Comments
 (0)