Skip to content

Commit

Permalink
Support downloading PDF files from DCM files.
Browse files Browse the repository at this point in the history
  • Loading branch information
birdeggb2777 committed Sep 22, 2024
1 parent f5ab079 commit 1702c55
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 10 deletions.
Binary file added bluelight/image/icon/black/download_pdf.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bluelight/image/icon/lite/download_pdf.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
41 changes: 31 additions & 10 deletions bluelight/scripts/viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,16 +195,37 @@ function PdfLoader(pdf, Sop) {
img2darkByClass("pdf", false);
leftLayout.setAccent(Sop.parent.SeriesInstanceUID);

if (getByid("PDFView")) {
if (getByid("PDFView").src != pdf)
getByid("PDFView").src = pdf;
}
else {
var iFrame = document.createElement("iframe");
iFrame.className = "PDFView";
iFrame.id = "PDFView";
iFrame.src = pdf;
getByid("PdfPage").appendChild(iFrame);
//如果瀏覽器支援顯示pdf
if ('PDF Viewer' in navigator.plugins) {
if (getByid("PDFView")) {
if (getByid("PDFView").src != pdf)
getByid("PDFView").src = pdf;
}
else {
var iFrame = document.createElement("iframe");
iFrame.className = "PDFView";
iFrame.id = "PDFView";
iFrame.src = pdf;
getByid("PdfPage").appendChild(iFrame);
}
} else {
if (getByid("PDFDownloadImg")) {
if (getByid("PDFDownloadImg").pdf != pdf)
getByid("PDFDownloadImg").pdf = pdf;
} else {
var img = new Image();
img.id = "PDFDownloadImg";
img.width = 100, img.height = 100;
img.src = "../image/icon/lite/download_pdf.png";
img.pdf = pdf;
img.onclick = function () {
var link = document.createElement('a');
link.href = this.pdf;
link.download = 'file.pdf';
link.dispatchEvent(new MouseEvent('click'));
}
getByid("PdfPage").appendChild(img);
}
}
}

Expand Down

0 comments on commit 1702c55

Please # to comment.