Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PDF #23

Open
Terabuck opened this issue Feb 6, 2023 · 7 comments
Open

PDF #23

Terabuck opened this issue Feb 6, 2023 · 7 comments
Assignees
Labels
enhancement New feature or request

Comments

@Terabuck
Copy link

Terabuck commented Feb 6, 2023

Is encapsulated PDF DICOM rendering possible? can it be included in the roadmap, please?

@cylien cylien added the enhancement New feature or request label Feb 6, 2023
@cylien
Copy link
Member

cylien commented Feb 6, 2023

We are still discussing how to display the pdf, there is a possible way to display the pdf: embedded in the current viewport, and the pdf viewer plugin should import it.

However, the support of all browsers has to be considered, any suggestions about displaying pdf are welcome as well.

@Terabuck
Copy link
Author

An iPhone PDFJS s shared in https://stackoverflow.com/questions/73653874/pdfjs-not-working-in-safari-blank-page-how-to-solve-issue/74192135#74192135

And, even using the deprecated Angular framework, the open source Osimis WebViewer has a very well documented process to recognize the instance "content type" in the series.manager.js. passing the binary data to /frontend/src/app/report before displaying the pdf in the viewport.

@cylien
Copy link
Member

cylien commented Mar 6, 2023

Done. 310d134

It is also available online

圖片

@cylien cylien closed this as completed Mar 6, 2023
@Terabuck
Copy link
Author

This is a great solution for a browser with built in PDF viewer, but on Chrome/Edge on Android, an inactive "Download file" button is displayed along with the pdf code id.

Screenshot_2023-07-30-10-40-18-886_com microsoft emmx

The same is displayed on desktop Chrome browser if the "Open PDFs in Chrome" option is disabled in chrome://settings/content/pdfDocuments

I see the PDF is rendered from the the following code in scripts/viewer.js
VIEWPORT.delPDFView(element); var iFrame = document.createElement("iframe"); iFrame.className = "PDFView"; iFrame.id = "PDFView_" + viewportNumber; iFrame.src = pdf; iFrame.style.width = iFrame.style.height = "100%"; iFrame.style.left = "0px"; iFrame.style.position = "absolute"; element.appendChild(iFrame); element.PDFView = iFrame;

In order to use pdfjs, pdf.js and pdf.worker.js (https://github.com/mozilla/pdf.js) were added to the scripts folder and declared in start.html, however I can´t figure out how to create an option or fallback to use of pdfjs on Android browsers. Any suggestions are welcome.

@Terabuck
Copy link
Author

Terabuck commented Jul 31, 2023

A solution to the present issue has been found:

Following the suggestions at https://www.3braintechnologies.com/effortlessly-open-pdfs-in-your-mobile-browser-using-pdf-js.html , the pdfjs "Prebuilt (modern browsers)" version was downloaded from https://mozilla.github.io/pdf.js/getting_started/#download and then uncompressed under bluelight/scripts/pdfjs

Then this single line was added to the function displayPDF(pdf) in bluelight/scripts/viewer.js

var PDFjsViewer = /bluelight/scripts/pdfjs/web/viewer.html??file=${pdf};

and the line
iFrame.src = pdf;

was switched to
iFrame.src = PDFjsViewer;

As all the pdfjs files are donwloaded to the bluelight folder structure, it is not required to deal with CORS, nor to declare pdf.js on the start.html file. The pdf viewer.html will load the js .

Now the PDF DICOM files are displayed on every desktop and mobile browser that has been tested so far.

@Terabuck
Copy link
Author

In order to allow the use of the built in PDF viewer, if present, the following line:
var PDFjsViewer = /bluelight/scripts/pdfjs/web/viewer.html??file=${pdf};

was changed to:

if (!navigator.pdfViewerEnabled) {
    // The browser does not support inline viewing of PDF files.
    var PDFjsViewer = `/bluelight/scripts/pdfjs/web/viewer.html??file=${pdf}`;
    // Create an iframe to display the PDF file
  }
else {
    // The browser supports inline viewing of PDF files.
    var PDFjsViewer = pdf;        
}

Now, the complete proposal is being packed for a pull request.

@cylien cylien reopened this Aug 1, 2023
@cylien
Copy link
Member

cylien commented Aug 1, 2023

@Terabuck thank you for your reporting. We will discuss how to display/download on browsers in an Android environment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants