Skip to content

Commit 1702c55

Browse files
committed
Support downloading PDF files from DCM files.
1 parent f5ab079 commit 1702c55

File tree

3 files changed

+31
-10
lines changed

3 files changed

+31
-10
lines changed
24.8 KB
Loading
1.91 KB
Loading

bluelight/scripts/viewer.js

Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -195,16 +195,37 @@ function PdfLoader(pdf, Sop) {
195195
img2darkByClass("pdf", false);
196196
leftLayout.setAccent(Sop.parent.SeriesInstanceUID);
197197

198-
if (getByid("PDFView")) {
199-
if (getByid("PDFView").src != pdf)
200-
getByid("PDFView").src = pdf;
201-
}
202-
else {
203-
var iFrame = document.createElement("iframe");
204-
iFrame.className = "PDFView";
205-
iFrame.id = "PDFView";
206-
iFrame.src = pdf;
207-
getByid("PdfPage").appendChild(iFrame);
198+
//如果瀏覽器支援顯示pdf
199+
if ('PDF Viewer' in navigator.plugins) {
200+
if (getByid("PDFView")) {
201+
if (getByid("PDFView").src != pdf)
202+
getByid("PDFView").src = pdf;
203+
}
204+
else {
205+
var iFrame = document.createElement("iframe");
206+
iFrame.className = "PDFView";
207+
iFrame.id = "PDFView";
208+
iFrame.src = pdf;
209+
getByid("PdfPage").appendChild(iFrame);
210+
}
211+
} else {
212+
if (getByid("PDFDownloadImg")) {
213+
if (getByid("PDFDownloadImg").pdf != pdf)
214+
getByid("PDFDownloadImg").pdf = pdf;
215+
} else {
216+
var img = new Image();
217+
img.id = "PDFDownloadImg";
218+
img.width = 100, img.height = 100;
219+
img.src = "../image/icon/lite/download_pdf.png";
220+
img.pdf = pdf;
221+
img.onclick = function () {
222+
var link = document.createElement('a');
223+
link.href = this.pdf;
224+
link.download = 'file.pdf';
225+
link.dispatchEvent(new MouseEvent('click'));
226+
}
227+
getByid("PdfPage").appendChild(img);
228+
}
208229
}
209230
}
210231

0 commit comments

Comments
 (0)