Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions blazorbootstrap/Components/PdfViewer/PdfViewer.razor
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
<li><span class="dropdown-item d-flex align-items-center" role="button" @onclick="FirstPageAsync"><Icon Class="mx-2" Name="IconName.ChevronBarUp" Size="IconSize.x5" /> Go to First Page</span></li>
<li><span class="dropdown-item d-flex align-items-center" role="button" @onclick="LastPageAsync"><Icon Class="mx-2" Name="IconName.ChevronBarDown" Size="IconSize.x5" /> Go to Last Page</span></li>
<li><span class="dropdown-item d-flex align-items-center" role="button" @onclick="ResetZoomAsync"><Icon Class="mx-2" Name="IconName.PlusSlashMinus" Size="IconSize.x5" /> Reset Zoom</span></li>
<li><span class="dropdown-item d-flex align-items-center" role="button" @onclick="DownloadPdf"><Icon Class="mx-2" Name="IconName.Download" Size="IconSize.x5" /> Download</span></li>
</ul>
</div>
</div>
Expand Down
4 changes: 4 additions & 0 deletions blazorbootstrap/Components/PdfViewer/PdfViewer.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,10 @@ private async Task ZoomOutAsync()
await PdfViewerJsInterop!.ZoomInOutAsync(objRef!, Id!, scale);
}

private async Task DownloadPdf()
{
await PdfViewerJsInterop!.DownloadPdfAsync(Url);
}
#endregion

#region Properties, Indexers
Expand Down
7 changes: 6 additions & 1 deletion blazorbootstrap/Components/PdfViewer/PdfViewerJsInterop.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
namespace BlazorBootstrap;

namespace BlazorBootstrap;

public class PdfViewerJsInterop : JsInteropBase
{
Expand Down Expand Up @@ -58,5 +59,9 @@ public async Task ZoomInOutAsync(object objRef, string elementId, double scale)
await SafeInvokeVoidAsync("zoomInOut", objRef, elementId, scale);
}

public async Task DownloadPdfAsync(string fileUrl)
{
await SafeInvokeVoidAsync("downloadPdf", fileUrl);
}
#endregion
}
8 changes: 8 additions & 0 deletions blazorbootstrap/wwwroot/blazor.bootstrap.pdf.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,14 @@ export function zoomInOut(dotNetHelper, elementId, scale) {
queueRenderPage(pdf, pdf.pageNum);
}

export function downloadPdf(fileUrl) {
const link = document.createElement('a');
link.href = fileUrl;
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
}

// resize
// print
// download
Expand Down