Skip to content

Commit 09bef9b

Browse files
authored
PdfViewer updates (#1258)
* Refactor PdfViewer zoom percentage enum and method Replaced PdfViewerManualZoomPercentage with PdfViewerZoomPercentage enum. Renamed SetManualZoomPercentage to SetZoomPercentage and updated usage. Improved variable handling and added null-checks in PdfViewer.razor.cs. * Add PdfViewer zoom enum and improve API documentation Updated PdfViewer docs to include Methods and Zoom enum tables. Renamed SetZoomPercentage to SetZoomPercentageAsync with full XML docs and attributes. Introduced PdfViewerZoomPercentage enum with annotated zoom levels for clearer API usage.
1 parent 8ca3d43 commit 09bef9b

4 files changed

Lines changed: 151 additions & 26 deletions

File tree

BlazorBootstrap.Demo.RCL/Components/Pages/Docs/PdfViewer/PdfViewer_Doc_01_Documentation.razor

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,18 @@
1818
<DocxTable TItem="PdfViewer" DocType="DocType.Parameters" />
1919
</Section>
2020

21+
<Section Class="p-0" Size="HeadingSize.H3" Name="Methods" PageUrl="@pageUrl" Link="methods">
22+
<DocxTable TItem="PdfViewer" DocType="DocType.Methods" />
23+
</Section>
24+
2125
<Section Class="p-0" Size="HeadingSize.H3" Name="Events" PageUrl="@pageUrl" Link="events">
2226
<DocxTable TItem="PdfViewer" DocType="DocType.Events" />
2327
</Section>
2428

29+
<Section Class="p-0" Size="HeadingSize.H3" Name="PdfViewerZoomPercentage Enum" PageUrl="@pageUrl" Link="pdf-viewer-zoom-percentage-enum">
30+
<DocxTable TItem="PdfViewerZoomPercentage" DocType="DocType.Enum" />
31+
</Section>
32+
2533
@code {
2634
private const string componentName = nameof(PdfViewer);
2735
private const string pageUrl = DemoRouteConstants.Docs_URL_PDFViewer;

blazorbootstrap/Components/PdfViewer/PdfViewer.razor.cs

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,25 @@ protected override async Task OnParametersSetAsync()
5959
await base.OnParametersSetAsync();
6060
}
6161

62-
public async Task SetManualZoomPercentage(PdfViewerManualZoomPercentage manualZoomPercentage)
62+
/// <summary>
63+
/// Asynchronously sets the zoom level of the PDF viewer to the specified percentage.
64+
/// </summary>
65+
/// <remarks>The zoom percentage is converted to a scale factor for rendering the PDF document. Ensure
66+
/// that the provided zoom percentage is within valid bounds to avoid unexpected display behavior.</remarks>
67+
/// <param name="zoomPercentage">The desired zoom percentage to apply to the PDF viewer. Must be a valid value defined by the
68+
/// PdfViewerZoomPercentage enumeration.</param>
69+
/// <returns>A task that represents the asynchronous operation of updating the zoom level.</returns>
70+
[AddedVersion("4.0.0")]
71+
[Description("Asynchronously sets the zoom level of the PDF viewer to the specified percentage.")]
72+
public async Task SetZoomPercentageAsync(PdfViewerZoomPercentage zoomPercentage)
6373
{
64-
zoomLevel = (int)manualZoomPercentage;
74+
zoomLevel = (int)zoomPercentage;
6575
var zp = GetZoomPercentage(zoomLevel);
66-
zoomPercentage = $"{zp}%";
76+
this.zoomPercentage = $"{zp}%";
6777
scale = 0.01 * zp;
68-
await PdfViewerJsInterop.ZoomInOutAsync(objRef!, Id!, scale);
78+
await PdfViewerJsInterop!.ZoomInOutAsync(objRef!, Id!, scale);
6979
}
80+
7081
[JSInvokable]
7182
public void DocumentLoaded(PdfViewerModel pdfViewerModel)
7283
{

blazorbootstrap/Enums/PdfViewerManualZoomPercentage.cs

Lines changed: 0 additions & 22 deletions
This file was deleted.
Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
namespace BlazorBootstrap;
2+
3+
/// <summary>
4+
/// Defines the available zoom percentages for the PDF viewer.
5+
/// </summary>
6+
[AddedVersion("4.0.0")]
7+
[Description("Defines the available zoom percentages for the PDF viewer.")]
8+
public enum PdfViewerZoomPercentage
9+
{
10+
/// <summary>
11+
/// Zoom to 25%.
12+
/// </summary>
13+
[AddedVersion("4.0.0")]
14+
[Description("Zoom to 25%.")]
15+
x25Percent = 1,
16+
17+
/// <summary>
18+
/// Zoom to 33%.
19+
/// </summary>
20+
[AddedVersion("4.0.0")]
21+
[Description("Zoom to 33%.")]
22+
x33Percent,
23+
24+
/// <summary>
25+
/// Zoom to 50%.
26+
/// </summary>
27+
[AddedVersion("4.0.0")]
28+
[Description("Zoom to 50%.")]
29+
x50Percent,
30+
31+
/// <summary>
32+
/// Zoom to 67%.
33+
/// </summary>
34+
[AddedVersion("4.0.0")]
35+
[Description("Zoom to 67%.")]
36+
x67Percent,
37+
38+
/// <summary>
39+
/// Zoom to 75%.
40+
/// </summary>
41+
[AddedVersion("4.0.0")]
42+
[Description("Zoom to 75%.")]
43+
x75Percent,
44+
45+
/// <summary>
46+
/// Zoom to 80%.
47+
/// </summary>
48+
[AddedVersion("4.0.0")]
49+
[Description("Zoom to 80%.")]
50+
x80Percent,
51+
52+
/// <summary>
53+
/// Zoom to 90%.
54+
/// </summary>
55+
[AddedVersion("4.0.0")]
56+
[Description("Zoom to 90%.")]
57+
x90Percent,
58+
59+
/// <summary>
60+
/// Zoom to 100%.
61+
/// </summary>
62+
[AddedVersion("4.0.0")]
63+
[Description("Zoom to 100%.")]
64+
x100Percent,
65+
66+
/// <summary>
67+
/// Zoom to 110%.
68+
/// </summary>
69+
[AddedVersion("4.0.0")]
70+
[Description("Zoom to 110%.")]
71+
x110Percent,
72+
73+
/// <summary>
74+
/// Zoom to 125%.
75+
/// </summary>
76+
[AddedVersion("4.0.0")]
77+
[Description("Zoom to 125%.")]
78+
x125Percent,
79+
80+
/// <summary>
81+
/// Zoom to 150%.
82+
/// </summary>
83+
[AddedVersion("4.0.0")]
84+
[Description("Zoom to 150%.")]
85+
x150Percent,
86+
87+
/// <summary>
88+
/// Zoom to 175%.
89+
/// </summary>
90+
[AddedVersion("4.0.0")]
91+
[Description("Zoom to 175%.")]
92+
x175Percent,
93+
94+
/// <summary>
95+
/// Zoom to 200%.
96+
/// </summary>
97+
[AddedVersion("4.0.0")]
98+
[Description("Zoom to 200%.")]
99+
x200Percent,
100+
101+
/// <summary>
102+
/// Zoom to 250%.
103+
/// </summary>
104+
[AddedVersion("4.0.0")]
105+
[Description("Zoom to 250%.")]
106+
x250Percent,
107+
108+
/// <summary>
109+
/// Zoom to 300%.
110+
/// </summary>
111+
[AddedVersion("4.0.0")]
112+
[Description("Zoom to 300%.")]
113+
x300Percent,
114+
115+
/// <summary>
116+
/// Zoom to 400%.
117+
/// </summary>
118+
[AddedVersion("4.0.0")]
119+
[Description("Zoom to 400%.")]
120+
x400Percent,
121+
122+
/// <summary>
123+
/// Zoom to 500%.
124+
/// </summary>
125+
[AddedVersion("4.0.0")]
126+
[Description("Zoom to 500%.")]
127+
x500Percent
128+
}

0 commit comments

Comments
 (0)