【发布时间】:2011-12-09 15:11:32
【问题描述】:
我们正在使用 Reporting Services 生成 PDF 报告,我们需要将其呈现到浏览器窗口并嵌入到浏览器中。我们已经这样做了很长时间,并且一直有效......直到 IE9。
在 IE6、IE7 和 IE8 中,我们从 Reporting Services 生成表示 PDF 报告的字节数组,然后将其二进制写入浏览器,一切正常。 PDF 显示嵌入在浏览器中。
在 IE9 中,我们尝试了同样的事情并且 PDF 没有嵌入到浏览器窗口中。浏览器窗口保持打开状态并且为空白/空,并且 PDF 在 Adobe Reader 中的单独窗口中打开。
这是我们代码的 sn-p:
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)
{
// ...
}
我们可以做些什么来让 PDF 呈现并嵌入到 IE9 浏览器窗口中?
谢谢!
【问题讨论】:
-
能否包含 acrobat reader 版本信息? (在 IE 6/7/8 boxen 和与 IE9 结合使用的 boxen 上)
-
感谢林恩提供的信息。这很有帮助。我尝试了 Adobe Reader 版本 9.4.6 和 10.1.1(在两台不同的计算机上 - 都是 Windows Server 2008 R2,带有 IE9),两个版本的 Reader 都有同样的问题。该问题似乎源于使用 64 位版本的 IE9。使用 64 位版本的 IE9 时,PDF 在 Adobe Reader 应用程序中打开,而不是在浏览器窗口中打开。如果我们使用 32 位版本的 IE9,PDF 在浏览器窗口中打开,就像我们在以前版本的 IE 和 Adobe Reader 中一样。因此,需要注意的是,在这种情况下使用 32 位 IE。
-
添加到我已经存在的答案中。您是通过 http 还是 https 发送?
标签: c# pdf 64-bit pdf-generation internet-explorer-9