I'm trying to view a Pdf file that I found online.

Normally, when I attempt to open a Pdf file, Firefox displays it in its default Pdf viewer (called pdfjs, I believe). This is good and normal behavior.

with this specific Pdf that I found online, I click the link to its location, and Firefox brings up the download dialog. It describes the file as a "binary file", even though the file is a Pdf that I can download and view natively.

I'm assuming the web-server is "not telling" Firefox that this Pdf file is, in fact, a Pdf file. So Firefox can only assume that it is a "binary file".

          This spurred me to wonder the question...

If I were to ever encounter this annoyance again, instead of downloading the file, can I force Firefox to open a file (online or otherwise) in its default Pdf viewer?

Attempted Solutions:

  1. I tried the answer from How to call firefox built-in pdf viewer (pdf.js) manually?, but to no avail. Firefox just attempts to download the "binary file".
  2. I added view-source: to the beginning of the Pdf's location (i.e. view-source:https://www.website.com/pdf.pdf), I just get the raw ASCII text displayed of the Pdf file.

PS: I'm using Firefox 48.0.2 ...
Yes, it's old....

As requested:

Screenshot of Response and Request Headers

  • It's possible the website is using the download HTML5 attribute. <a href="document.pdf" download="document.pdf">Download here!</a>. This will force your browser to save the file instead of opening it like it would normally. – Michael Frank May 28 '19 at 20:41
  • @MichaelFrank Firefox's inspector shows that it is a regular <a href="document.pdf">PDF</a>. – I_Don't_Code May 28 '19 at 20:47
  • There are other ways to force it, like the HTTP Header content-disposition. There's a good reason to do this with certain PDFs, like forms or receipts, where you want the user to save the document somewhere appropriate and not in a temp folder where files that open in browser are put by default. Anyway, you're asking for solutions and workarounds, but I'm not so sure there will be one. – Michael Frank May 28 '19 at 20:56
  • @MichaelFrank By the way...This is unrelated to the question but you should change your Profile's website link...It's a spam website that is not appropriate for work – I_Don't_Code May 28 '19 at 21:06
  • Ooops. Good catch, that's an old domain. – Michael Frank May 28 '19 at 21:10

There are several ways that sites can force your browser to download a file instead of opening it directly:

The download HTML Attribute

This attribute on an anchor tag will attempt to force your browser to download the file instead of processing it in the way it normally would.

Generally this is used when you need to take an automatically generated document name and present it as something nice for the user.

Usage: <a href="http://www.website.com/path/to/YourDocument.pdf" download="YourDocument.pdf">...

I have not yet found a way to work around this, but since the real cause of your problem lies below, I haven't researched it entirely...

HTTP Headers


A webserver can respond to a request for a document with the Content-Disposition header to describe how the browser should receive the file.

Content-Disposition: Attachment will tell the browser that it should download the file, rather than process it as it normally would.

Content-Disposition: Inline will tell the browser that it can be displayed inside the webpage, or as the webpage.

Here is a Firefox addon that will take Attachment headers and replace them with Inline headers:


Technically, it intercepts Content-Disposition: attachment Headers and rewrites them on the fly to Content-Disposition: inline. It also allows you to specify websites that should and should-not use this rewrite.

As with most addons, your mileage may vary.


A webserver can respond to a request for a document with the Content-Type header to describe the type of document it is returning to the browser.

Content-Type: application/octet-stream is defined as "arbitrary binary data" and is basically only downloadable as a file, the browser won't know what to do with it otherwise.

This is what you see when your browser requests the PDF file you are attempting to view.

Content-Type: application/pdf is what you would probably need if you wanted to view this file in your browser, or at least have Firefox understand what the file is and how to handle it correctly.

Here is a Firefox addon that can be set to listen for, and rewrite Content-Type headers based on their content.

Note: Modifying how your browser handles MIME types can be dangerous.


Again, this addon may or may not work in all cases.

  • Although a useful tool, this doesn't seem to solve my particular situation. Could there be another reason why Firefox sees the pdf file as a "binary file" and not a "pdf file? I think that's the issue: Firefox doesn't interpret this document.pdf file as a Pdf filetype, even though it is. – I_Don't_Code May 28 '19 at 21:33
  • Can you open the Inspector and grab the HTTP request/response headers for the download? Add it into your question if you can get it. – Michael Frank May 28 '19 at 21:34
  • I have them: What specifically should I paste? A picture? Raw text of a certain section? – I_Don't_Code May 28 '19 at 23:50
  • The Response Header titled "Content-Security-Policy" has "style-src 'unsafe-inline' github.githubassets.com". – I_Don't_Code May 28 '19 at 23:58
  • You need the Content-Disposition header like seen in this screenshot: i.stack.imgur.com/dUEIJ.png – Michael Frank May 29 '19 at 0:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.