Wednesday, 5 March 2008

Content-type application/pdf does not work using Firefox on Mac

Today we had a customer complain they could not open our invoices which are pdf's produced via a cgi script.

It quickly became apparent that it only happens in Firefox on a Mac. Firefox on other platforms has no issues, nor does Safari on a Mac.

A quick google uncovered this known bug.

https://bugzilla.mozilla.org/show_bug.cgi?id=416094

It appears firefox on Max ignores the Content-Type header and will only automatically open a pdf when presented with a .pdf file extension.

I managed to 'solve' the problem by adding the following http header to the output.

Content-Disposition: inline; filename="invoice.pdf"

This just tells the browser the default file name and thus gets round the issue. Still works in IE and Firefox on a PC and fixes the issue on a Mac.

No comments: