From 59cfdcc6f6d8ec7c3314255ea15978bdbd0a615f Mon Sep 17 00:00:00 2001 From: Diego Martinez Date: Mon, 25 Nov 2024 14:58:12 -0300 Subject: [PATCH] Add Manual Zoom Support --- .../Components/PdfViewer/PdfViewer.razor.cs | 8 +++++++ .../Enums/PdfViewerManualZoomPercentage.cs | 22 +++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 blazorbootstrap/Enums/PdfViewerManualZoomPercentage.cs diff --git a/blazorbootstrap/Components/PdfViewer/PdfViewer.razor.cs b/blazorbootstrap/Components/PdfViewer/PdfViewer.razor.cs index 5a0056530..b8ff073c4 100644 --- a/blazorbootstrap/Components/PdfViewer/PdfViewer.razor.cs +++ b/blazorbootstrap/Components/PdfViewer/PdfViewer.razor.cs @@ -59,6 +59,14 @@ protected override async Task OnParametersSetAsync() await base.OnParametersSetAsync(); } + public async Task SetManualZoomPercentage(PdfViewerManualZoomPercentage manualZoomPercentage) + { + zoomLevel = (int)manualZoomPercentage; + var zp = GetZoomPercentage(zoomLevel); + zoomPercentage = $"{zp}%"; + scale = 0.01 * zp; + await PdfViewerJsInterop.ZoomInOutAsync(objRef!, Id!, scale); + } [JSInvokable] public void DocumentLoaded(PdfViewerModel pdfViewerModel) { diff --git a/blazorbootstrap/Enums/PdfViewerManualZoomPercentage.cs b/blazorbootstrap/Enums/PdfViewerManualZoomPercentage.cs new file mode 100644 index 000000000..067a304ba --- /dev/null +++ b/blazorbootstrap/Enums/PdfViewerManualZoomPercentage.cs @@ -0,0 +1,22 @@ +namespace BlazorBootstrap; + +public enum PdfViewerManualZoomPercentage +{ + x25Percent = 1, + x33Percent, + x50Percent, + x67Percent, + x75Percent, + x80Percent, + x90Percent, + x100Percent, + x110Percent, + x125Percent, + x150Percent, + x175Percent, + x200Percent, + x250Percent, + x300Percent, + x400Percent, + x500Percent +}