Skip to content

Commit 687dfa7

Browse files
Merge pull request #1492 from syncfusion-content/978978-pv-print
978978: Modified the print documentation for the blazor pdfviewer
2 parents 2c60786 + 545d0c2 commit 687dfa7

File tree

1 file changed

+121
-0
lines changed
  • Document-Processing/PDF/PDF-Viewer/blazor

1 file changed

+121
-0
lines changed

Document-Processing/PDF/PDF-Viewer/blazor/print.md

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,127 @@ The SfPdfViewer supports printing the loaded PDF by default. Enable or disable t
5252
5353
```
5454

55+
## EnablePrintRotation in the Blazor SfPdfViewer
56+
57+
[EnablePrintRotation](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.SfPdfViewer.PdfViewerBase.html#Syncfusion_Blazor_SfPdfViewer_PdfViewerBase_EnablePrintRotation) controls whether landscape pages are auto-rotated to best fit when printing. Default: true. Set to false to preserve the original page orientation and suppress automatic rotation during print.
58+
59+
```cshtml
60+
61+
@using Syncfusion.Blazor.SfPdfViewer
62+
63+
<SfPdfViewer2 Height="100%"
64+
Width="100%"
65+
DocumentPath="@DocumentPath"
66+
EnablePrintRotation="true" />
67+
68+
@code{
69+
public string DocumentPath { get; set; } = "wwwroot/Data/PDF_Succinctly.pdf";
70+
}
71+
72+
```
73+
74+
## Print modes in the Blazor SfPdfViewer
75+
76+
[PrintMode](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.SfPdfViewer.PdfViewerBase.html#Syncfusion_Blazor_SfPdfViewer_PdfViewerBase_PrintMode) specifies how the print dialog is opened. Default: PrintMode.Default (prints from the same window). Supported values:
77+
78+
- [PrintMode.Default](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.SfPdfViewer.PrintMode.html#Syncfusion_Blazor_SfPdfViewer_PrintMode_Default) — Opens the print dialog in the same window.
79+
- [PrintMode.NewWindow](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.SfPdfViewer.PrintMode.html#Syncfusion_Blazor_SfPdfViewer_PrintMode_NewWindow) — Opens the print dialog from a new browser window/tab, which can be useful depending on browser popup policies.
80+
81+
```cshtml
82+
83+
@using Syncfusion.Blazor.SfPdfViewer
84+
85+
<SfPdfViewer2 Height="100%"
86+
Width="100%"
87+
DocumentPath="@DocumentPath"
88+
PrintMode="PrintMode.NewWindow" />
89+
90+
@code{
91+
public string DocumentPath { get; set; } = "wwwroot/Data/PDF_Succinctly.pdf";
92+
}
93+
94+
```
95+
96+
## PrintScaleFactor in the Blazor SfPdfViewer
97+
98+
[PrintScaleFactor](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.SfPdfViewer.PdfViewerBase.html#Syncfusion_Blazor_SfPdfViewer_PdfViewerBase_PrintScaleFactor) sets the scale used when rendering pages for printing. By default the scale factor set as 1.0 (prints at the on-screen scale). Valid range from 0.5 to 5.0. Higher values can improve output clarity for documents with smaller page dimensions and may increase print processing time.
99+
100+
```cshtml
101+
102+
@using Syncfusion.Blazor.SfPdfViewer
103+
104+
<SfPdfViewer2 Height="100%"
105+
Width="100%"
106+
DocumentPath="@DocumentPath"
107+
PrintScaleFactor="2" />
108+
109+
@code{
110+
public string DocumentPath { get; set; } = "wwwroot/Data/PDF_Succinctly.pdf";
111+
}
112+
113+
```
114+
115+
## Print Events in Blazor SfPdfViewer
116+
117+
The following events are available in the SfPdfViewer component.
118+
119+
|Name|Description|
120+
|---|---|
121+
|PrintStart|Triggers when a print action starts.|
122+
|PrintEnd|Triggers when a print action is completed.|
123+
124+
### PrintStart Event
125+
126+
The [PrintStart](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.SfPdfViewer.PdfViewerEvents.html#Syncfusion_Blazor_SfPdfViewer_PdfViewerEvents_PrintStart) event triggers when the print action is started.
127+
128+
#### Event Arguments
129+
130+
See [PrintStartEventArgs](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.SfPdfViewer.PrintStartEventArgs.html) for details such as Filename, Cancel option.
131+
132+
The following example illustrates how to handle the PrintStart event.
133+
134+
```cshtml
135+
136+
@using Syncfusion.Blazor.SfPdfViewer
137+
<SfPdfViewer2 DocumentPath="@DocumentPath" Height="100%" Width="100%">
138+
<PdfViewerEvents PrintStart="@PrintStart"></PdfViewerEvents>
139+
</SfPdfViewer2>
140+
@code{
141+
private string DocumentPath { get; set; } = "wwwroot/Data/PDF_Succintly.pdf";
142+
public async Task PrintStart(PrintStartEventArgs args)
143+
{
144+
Console.WriteLine($"Printed File Name: {args.FileName}");
145+
}
146+
}
147+
148+
```
149+
150+
### PrintEnd Event
151+
152+
The [PrintEnd](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.SfPdfViewer.PdfViewerEvents.html#Syncfusion_Blazor_SfPdfViewer_PdfViewerEvents_PrintEnd) event triggers when an annotation is added to a page in the PDF document.
153+
154+
#### Event Arguments
155+
156+
See [PrintEndEventArgs](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.SfPdfViewer.PrintEndEventArgs.html) for details such as Filename.
157+
158+
The following example illustrates how to handle the PrintEnd event.
159+
160+
```cshtml
161+
162+
@using Syncfusion.Blazor.SfPdfViewer
163+
<SfPdfViewer2 DocumentPath="@DocumentPath" Height="100%" Width="100%">
164+
<PdfViewerEvents PrintEnd="@PrintEnd"></PdfViewerEvents>
165+
</SfPdfViewer2>
166+
@code{
167+
private string DocumentPath { get; set; } = "wwwroot/Data/PDF_Succintly.pdf";
168+
public async Task PrintEnd(PrintEndEventArgs args)
169+
{
170+
Console.WriteLine($"Printed File Name: {args.FileName}");
171+
}
172+
}
173+
174+
```
175+
55176
## See also
56177

57178
* [Download in Blazor SfPdfViewer component](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/blazor/saving-pdf-file#download-in-blazor-sfpdfviewer-component)

0 commit comments

Comments
 (0)