Unable to download PDFs in embedded pdf.js viewer
Example Site: https://mcpsc.mo.gov/media/pdf/genesis-school-inc-revocation-hearing but I've had it happen on several sites.
On this page, I am not able to click the download button built into the pdf.js viewer and have it download - it clicks and does nothing. If I right click in the frame and click "Show only this frame", then I can download the PDF using that same button. Any ideas?
Ausgewählte Lösung
Great workaround!
The family resemblance is because both the website and Firefox use code from the pdf.js PDF viewer project. There are a couple tells that the PDF is displaying in a website's custom viewer:
- The magnifying glass at the left end of the viewer toolbar opens a custom Find bar instead of Firefox's Find bar
- There is a button to upload your own PDF into the viewer
- The button selection and style do not match the changes in recent versions of Firefox
The reason the download button doesn't work in the framed viewer is that the site serves the download as a blob URL and the page's security settings don't allow it to load in a frame (this appears in the Web Console -- Ctrl+Shift+K -- after clicking the button):
"Content Security Policy: The page’s settings blocked the loading of a resource at blob:https://mcpsc . mo . gov/aafe5ab0-48db-462f-92a2-66a6d6eb065f (“frame-src”)."
The site could adjust its CSP rules to allow the download to load into the frame. Or maybe it would make more sense if they directed the download to a new tab as a workaround.
Diese Antwort im Kontext lesen 👍 1Alle Antworten (1)
Ausgewählte Lösung
Great workaround!
The family resemblance is because both the website and Firefox use code from the pdf.js PDF viewer project. There are a couple tells that the PDF is displaying in a website's custom viewer:
- The magnifying glass at the left end of the viewer toolbar opens a custom Find bar instead of Firefox's Find bar
- There is a button to upload your own PDF into the viewer
- The button selection and style do not match the changes in recent versions of Firefox
The reason the download button doesn't work in the framed viewer is that the site serves the download as a blob URL and the page's security settings don't allow it to load in a frame (this appears in the Web Console -- Ctrl+Shift+K -- after clicking the button):
"Content Security Policy: The page’s settings blocked the loading of a resource at blob:https://mcpsc . mo . gov/aafe5ab0-48db-462f-92a2-66a6d6eb065f (“frame-src”)."
The site could adjust its CSP rules to allow the download to load into the frame. Or maybe it would make more sense if they directed the download to a new tab as a workaround.