We’re using Reporting Services to generate a PDF report and we need it to be rendered out to the browser window AND embedded in the browser. We’ve been doing this a long time and it has always worked … until IE9.
In IE6, IE7, and IE8, we generate the byte array from Reporting Services that represents the PDF report and binary write it out to the browser, and everything works great. The PDF displays embedded in the browser.
In IE9, we try the same exact thing and the PDF is NOT embedded in the browser window. The browser window stays open and is blank/empty, and the PDF is opened in Adobe Reader in a separate window.
Here’s a snippet of our code:
try
{
// Set all the Reporting Services variables and parameters and render the report
// ...
byte[] result = rs.Render(format, devInfo, out extension, out mimeType, out encoding, out warnings, out streamIDs);
// Force the render out of the report to the browser
Response.Clear();
Response.ClearContent();
Response.ClearHeaders();
Response.AppendHeader("content-length", result.Length.ToString());
Response.AppendHeader("Pragma", "cache");
Response.AppendHeader("Expires", "3600");
Response.Buffer = true;
Response.Cache.SetCacheability(HttpCacheability.Private);
Response.CacheControl = "private";
Response.Charset = System.Text.UTF8Encoding.UTF8.WebName;
Response.ContentEncoding = System.Text.UTF8Encoding.UTF8;
switch (outputformat)
{
case "PDF":
Response.AppendHeader("content-disposition", "inline; filename=report.pdf");
Response.ContentType = "application/pdf";
break;
default:
break;
}
Response.BinaryWrite(result);
Response.Flush();
Response.Close();
Response.End();
}
catch (System.Exception ex)
{
// ...
}
What can we do to get the PDF rendered and embedded in the IE9 broswer window?
Thanks!
Take a look at this forum post:
http://forums.adobe.com/message/3331557#3331557#3331557
Also, this whole thread talks about different fixes to make different versions of IE work. There are multiple things that can cause this issue.
http://forums.adobe.com/thread/758489
One reader also noted that it MUST end in PDF, which it looks like you are doing.
Keep in mind, if you were using different versions of acrobat reader, this issue could actually be related to changes in Reader, and not IE.
In your comment, you noted a 64bit issue. Check out this SO answer re IE8/64bit vista:
Can't display PDF from HTTPS in IE 8 (on 64-bit Vista)
It appears that you’re already doing everything that he said he needed to do, in his final answer (namely, setting Cache control to private, and not setting Pragma: no-cache.)
It’s interesting to note, that the various responses have gone the way of manually adding the header via:
Instead of calling
Unsure there’s a difference, but it might be worth a shot.