Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PDF created on HTTP request won't open in Internet Explorer

I've got servlet that makes a PDF on the fly to the response, based on some parameters on the request. When I try to open/download this file in IE I get the following message:

"Unable to download [filename] from [site]. Unable to open this Internet site. The requested site is either unavaliable or cannot be found. Please try again later."

This is what i set to the response:

response.setHeader("Content-Disposition", "attachment;filename=" + title + ".pdf");

response.setContentType("application/pdf");

Everything is working fine with other browsers.

Update:

I've tried inline instead of attachment. This will open a new window instead of a open/save dialog (I would prefer to have the dialog), the error message is gone, but the new window is just empty in IE. Still working with other browsers.

I've tried simple, double and no quotes around the filename, which does not contain any unescaped characters. Double and no quotes makes no difference, but single ones are appended to the filename, which I of course don't want.

The filename contains no unescaped characters.

I've checked out the tests on this page, which says that attachement, with filename, no quotes, is passed for all browsers. This is what was used from the start.

Adding Content-Lenght header makes no difference.

Flying Saucer is used to make the PDF, by the way.

like image 557
Karine Avatar asked Feb 19 '23 00:02

Karine


1 Answers

I suggest taking a look at http://greenbytes.de/tech/tc2231/ which lists a whole bunch of test cases for how different browsers behave with different values for the Content-Disposition header. My guess is that the title contains spaces or some other special characters that need to be escaped, and IE is currently barfing on the non-escaped value.

like image 121
matt b Avatar answered Feb 21 '23 14:02

matt b