pipwerks / PDFObject

A lightweight JavaScript utility for dynamically embedding PDFs in HTML documents.
http://pdfobject.com/
Other
2.39k stars 986 forks source link

PDFObject stopped rendering and automatically downloads #275

Closed 365ging closed 2 years ago

365ging commented 2 years ago

This week the PDFObject that I have had implemented for a few years started not rendering in any browser and automatically downloading. The url that I'm using is from Azure Blob Storage. I have not changed the code at all. Is there any reason this would be happening?

pipwerks commented 2 years ago

PDFObject never forces PDFs to download. In my experience, if the PDF is no longer displaying inline, and is automatically downloading, it's usually due to the server's Content-Disposition header settings. Check your server and/or the server-side code that requests the file and ensure Content-Disposition for PDFs is set to inline and not attachment. See https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Disposition for details.

Some browsers also enable users to change how PDFs are handled. For example https://support.mozilla.org/en-US/kb/view-pdf-files-firefox-or-choose-another-viewer I once accidentally set Firefox to automatically download PDFs instead of rendering in a new tab (though this shouldn't affect PDFs embedded via PDFObject within an HTML page).

Good luck