29 ms·
I've always wondered why some sites can serve PDFs that my browser (firefox) can view inline (my preferred method), rather than forcing me to download the file
by maccard 5y ago
I've always wondered why some sites can serve PDFs that my browser (firefox) can view inline (my preferred method), rather than forcing me to download the file and open in a separate application
- chrismorgan 5y agoIt depends on the Content-Disposition header: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Disposition https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Co.... There are extensions that let you intercept this header, e.g. https://addons.mozilla.org/en-GB/firefox/addon/no-pdf-download/ https://addons.mozilla.org/en-GB/firefox/addon/no-pdf-downlo... which per https://github.com/MorbZ/no-pdf-download/blob/c924d657f33398e2a3a51a7a67608b6156a99124/app/src/headers.js https://github.com/MorbZ/no-pdf-download/blob/c924d657f33398... detects the content-type and if it’s PDFy replaces the content-disposition header with “inline”. (Clicking on a link that has the download attribute set also affects things: https://developer.mozilla.org/en-US/docs/Web/API/HTMLAnchorElement/download https://developer.mozilla.org/en-US/docs/Web/API/HTMLAnchorE....)
- maccard 5y agoToday I am one of the lucky 10,000 [0]. I learned about a new header, and fixed an issue I've had for _years_ [0] https://xkcd.com/1053/ https://xkcd.com/1053/
- deleted 5y ago[deleted]