# HG changeset patch # User Alain Mazy # Date 1727968752 -7200 # Node ID 952674a812c206cd1869f405491411decd1e7dd8 # Parent 0a2b450cec3a655301c656bd61a02b38ce4bfad4 Added a Download button in the PDF viewer toolbar diff -r 0a2b450cec3a -r 952674a812c2 Applications/StoneWebViewer/NEWS --- a/Applications/StoneWebViewer/NEWS Thu Oct 03 14:23:14 2024 +0200 +++ b/Applications/StoneWebViewer/NEWS Thu Oct 03 17:19:12 2024 +0200 @@ -3,6 +3,8 @@ * Remember the previous layout when re-opening the viewer. * Added a Print button in the PDF viewer toolbar. +* Added a Download button in the PDF viewer toolbar. + Version 2.6 (2024-08-31) ======================== diff -r 0a2b450cec3a -r 952674a812c2 Applications/StoneWebViewer/WebApplication/index.html --- a/Applications/StoneWebViewer/WebApplication/index.html Thu Oct 03 14:23:14 2024 +0200 +++ b/Applications/StoneWebViewer/WebApplication/index.html Thu Oct 03 17:19:12 2024 +0200 @@ -898,6 +898,14 @@
+ + -
diff -r 0a2b450cec3a -r 952674a812c2 Applications/StoneWebViewer/WebApplication/pdf-viewer.js --- a/Applications/StoneWebViewer/WebApplication/pdf-viewer.js Thu Oct 03 14:23:14 2024 +0200 +++ b/Applications/StoneWebViewer/WebApplication/pdf-viewer.js Thu Oct 03 17:19:12 2024 +0200 @@ -92,6 +92,23 @@ }); }, methods: { + Download: function() { + if (this.pdfDoc !== null) { + const blob = new Blob([this.pdf], { type: 'application/pdf'}); + const blobUrl = URL.createObjectURL(blob); + + const a = document.createElement('a'); + a.href = blobUrl; + a.download = "report.pdf"; + + document.body.appendChild(a); + a.click(); + document.body.removeChild(a); + + // Revoke the object URL to free up memory + URL.revokeObjectURL(blobUrl); + } + }, Print: function() { if (this.pdfDoc !== null) { if (0) { // works on Chrome but with a popup that is blocked by default !