PDF is shown as binary text in browser instead of being downloaded
Why is this and how can I download this PDF file?
The website is broken and is not serving PDF files correctly. Contact [email protected].
Using the Firefox developer tools (press f12, select "Net", then select "All" we can see the response and request headers:
Content-Disposition inline;filename=U1a.pdf
The above tells the browser to serve the page content inline:
In a regular HTTP response, the Content-Disposition response header is a header indicating if the content is expected to be displayed inline in the browser, that is, as a Web page or as part of a Web page, or as an attachment, that is downloaded and saved locally.
You can open the PDF by saving the page locally and opening the PDF:
-
Right click on the page and select "Save as" (or press ctrls)
-
Choose a directory and click "Save".
-
Navigate to the chosen directory in
Explorer
. -
Double click
U1a.pdf
.
Related videos on Youtube
user1580348
Updated on September 18, 2022Comments
-
user1580348 over 1 year
In Chrome, when I enter a URL to a PDF file, usually the browser's Save dialog opens to save the PDF file to my hard disk, for example:
http://www.pdf995.com/samples/pdf.pdf
Now I have found a PDF URL where this, unfortunately, does not work:
https://formulare.bmf.gv.at/service/formulare/inter-Steuern/pdfd/2015/U1a.pdf
With this PDF URL, no Save dialog is opened and the binary text of this PDF is shown in the browser:
Why is this and how can I make it download automatically when I click the URL?
OS: Windows 7 x64 SP1
-
DavidPostill over 7 yearsDid you actually try this? It doesn't work. The website is not serving PDF files correctly. See my answer.
-
user1580348 over 7 yearsThank you. But I don't want to view the PDF in the browser, I just want to download the PDF when I click on the URL.
-
user1580348 over 7 yearsThank you. How is the website not serving PDF files correctly? Can you please explain the technical details?
-
DavidPostill over 7 years@user1580348 There are many different possibilities ...
-
user1580348 over 7 yearsStrange: When I enter the PDF URL
https://formulare.bmf.gv.at/service/formulare/inter-Steuern/pdfd/2015/U1a.pdf
in Firefox, the PDF is displayed correctly as PDF in Firefox (without downloading). -
user1580348 over 7 yearsFor example? Can you name some, please?
-
DavidPostill over 7 years@user1580348 The most likely is that the web server is serving the wrong mime type for pdf files and is serving it as html. See Properly Configuring Server MIME Types
-
Devidas over 7 yearsOk sorry I missunderstood. and did not read your question thoroughly.
-
user1580348 over 7 yearsI have now activated
Chrome PDF Viewer
inchrome://plugins
, but Chrome still displays the PDF as binary text. So why this (displaying the PDF in the browser) is working in Firefox and not in Chrome? -
Devidas over 7 yearsbut to my surprise it did open in Mozilla and not in chrome very strange behavior I agree to your point.
-
Devidas over 7 yearsthis can be bug in either web server or chrome. More probable it is chrome bug as it opens in Mozilla
-
user1580348 over 7 yearsAlso in Internet Explorer the PDF is displayed correctly as PDF (no download).
-
user1580348 over 7 yearsIn Opera there is a strange security warning: It says that it is not possible to complete the secure transaction! ???
-
user1580348 over 7 yearsIMO, this cannot be, as Firefox shows a correct MIME type for the PDF URL:
http://i.imgur.com/iPoybDn.png
(application/pdf
). -
DavidPostill over 7 years@user1580348 It fails in Firefox in the same way for me. But works in IE. Strange.
-
John Keates over 7 yearsMight be a attachment status header set to inline
-
DavidPostill over 7 years@JohnKeates You got it
Content-Disposition inline;filename=U1a.pdf
-
DavidPostill over 7 years@user1580348 Answer updated.
-
user1580348 over 7 yearsThank you very much for the information! So does this indicate that it's the server's fault or it's Chrome's fault?
-
user1580348 over 7 yearsOr more precisely: Is it the server's fault or is there an error in the website's HTML code containing the link to this PDF file?
-
DavidPostill over 7 years@user1580348
Content-Disposition inline;filename=U1a.pdf
is the response from the server, so it is the server that is misconfigured. -
user1580348 over 7 yearsI needed to know whom I should blame: The server admin or the website developer. BTW, how could the server admin fix this? Thank you! (I am not maintaining the site; it's just for curiosity).
-
DavidPostill over 7 years@user1580348 I would ask both of them. It depends where they have decided to split their responsibilities ...