Search code examples
javainternet-explorerpdfflying-saucer

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.


Solution

  • This been a while, but thought I should update this, as a solution was found.

    The CMS in use was adding some headers wich I did not take into consideration at first:

    • Cache-Control: private
    • Pragma: no-cache

    Seems to be a download problem with IE, if there is no caching. Those headers were changed in an upgrade of the CMS, and that solved the problem.

    Example:

    • Cache-Control: public, max-age=31536000
    • Date: Thu, 06 Dec 2012 14:14:14 GMT
    • Expires: Fri, 06 Dec 2013 14:14:14 GMT