From fece3c39f07790ee81d6a2c0a2cbb8e06c731e81 Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Sun, 8 Jun 2025 15:29:37 +0800 Subject: [PATCH 1/3] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=E8=8E=B7?= =?UTF-8?q?=E5=BE=97=E7=BB=9D=E5=AF=B9=E8=B7=AF=E5=BE=84=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../PdfViewer.razor.cs | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/components/BootstrapBlazor.PdfViewer/PdfViewer.razor.cs b/src/components/BootstrapBlazor.PdfViewer/PdfViewer.razor.cs index 5ff5cd98..07a4fb6f 100644 --- a/src/components/BootstrapBlazor.PdfViewer/PdfViewer.razor.cs +++ b/src/components/BootstrapBlazor.PdfViewer/PdfViewer.razor.cs @@ -39,7 +39,10 @@ public partial class PdfViewer /// Gets or sets whether to use Google Docs for PDF rendering. Default is false. /// [Parameter] - public bool UseGoogleDocs { get; set; } = false; + public bool UseGoogleDocs { get; set; } + + [Inject, NotNull] + private NavigationManager? NavigationManager { get; set; } private string? ClassString => CssBuilder.Default("bb-pdf-viewer-container") .AddClassFromAttributes(AdditionalAttributes) @@ -85,7 +88,7 @@ protected override async Task OnAfterRenderAsync(bool firstRender) if (rerender) { - await InvokeVoidAsync("loadPdf", Id, _url); + await InvokeVoidAsync("loadPdf", Id, GetAbsoluteUri(_url)); } } @@ -97,9 +100,20 @@ protected override async Task OnAfterRenderAsync(bool firstRender) { LoadedCallaback = nameof(TriggerOnLoaded), NotSupportCallback = nameof(TriggerNotSupportCallback), - Url + Url = GetAbsoluteUri(Url) }); + private string GetAbsoluteUri(string? url) + { + url ??= string.Empty; + if (string.IsNullOrEmpty(url) || !UseGoogleDocs) + { + return url; + } + var uri = NavigationManager.ToAbsoluteUri(url); + return uri.AbsoluteUri; + } + /// /// Trigger OnLoaded callback when the PDF document is loaded. /// From 08d40b073c8907efcc364bcf5e9f4780a0c9929d Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Sun, 8 Jun 2025 15:29:52 +0800 Subject: [PATCH 2/3] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=20embedded=3Dtru?= =?UTF-8?q?e=20=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/BootstrapBlazor.PdfViewer/PdfViewer.razor.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/BootstrapBlazor.PdfViewer/PdfViewer.razor.js b/src/components/BootstrapBlazor.PdfViewer/PdfViewer.razor.js index 78e176ee..85d4def6 100644 --- a/src/components/BootstrapBlazor.PdfViewer/PdfViewer.razor.js +++ b/src/components/BootstrapBlazor.PdfViewer/PdfViewer.razor.js @@ -34,7 +34,7 @@ export async function loadPdf(id, url) { const useGoogleDocs = el.getAttribute('data-bb-google-docs') === 'true'; if (useGoogleDocs) { - url = `https://docs.google.com/viewer?url=${url}` + url = `https://docs.google.com/viewer?url=${url}&embedded=true` } viewer.src = url; } From 6592e87f055646b4c5c82dfd873b6542770bb57c Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Sun, 8 Jun 2025 15:30:00 +0800 Subject: [PATCH 3/3] chore: bump version 9.0.3 --- .../BootstrapBlazor.PdfViewer/BootstrapBlazor.PdfViewer.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/BootstrapBlazor.PdfViewer/BootstrapBlazor.PdfViewer.csproj b/src/components/BootstrapBlazor.PdfViewer/BootstrapBlazor.PdfViewer.csproj index bd509d97..e1e6b20a 100644 --- a/src/components/BootstrapBlazor.PdfViewer/BootstrapBlazor.PdfViewer.csproj +++ b/src/components/BootstrapBlazor.PdfViewer/BootstrapBlazor.PdfViewer.csproj @@ -1,7 +1,7 @@ - 9.0.2 + 9.0.3