1

My Firefox and Chrome usually open PDF files very nicely, without asking and within the browser window.

When clicking on a link to a PDF on our own website:

  • Firefox asks if it should download them, to see it I need to open the download history.
  • Chrome downloads it automatically, but here as well, opening the PDF needs an extra click.

If I copy the PDF to a different Server (Django installation with lighttpd), Firefox and Chrome will display it nicely as usual.

What's wrong?

Philipp Zedler
  • 119
  • 1
  • 4

2 Answers2

3

See How to force files to open in browser instead of download (pdf)? which has an answer from ColinM that tells you exactly what the headers should be:

To indicate to the browser that the file should be viewed in the browser:

Content-Type: application/pdf
Content-Disposition: inline; filename="filename.pdf"

To have the file downloaded rather than viewed:

Content-Type: application/pdf
Content-Disposition: attachment; filename="filename.pdf"

EDIT: The quotes around the filename are required if the filename contains special characters such as filename[1].pdf which may otherwise break the browser's ability to handle the response.

Stephen Ostermiller
  • 99,822
  • 18
  • 143
  • 364
0

The solution was rather special.

The server had the default mime-type application/octet-stream for PDF files. After changing this to application/pdf everything worked fine.

In the lighttpd configuration I achieved the change by adding this definition:

mimetype.assign += ( ".pdf" => "application/pdf" )
Philipp Zedler
  • 119
  • 1
  • 4