c# - 如何在 ASP.Net 和 C# 网页中将 Reporting Services 报告显示为内联 PDF?

标签 c# .net asp.net reporting-services

我需要在 ASP.Net 网页(使用 C# 服务器端脚本)中显示报表的预览。预览需要是 PDF 而不是 HTML 并内联显示(可能在 iframe 中?)。

是否可以指定呈现为 PDF 的报告的标题,以便其“Content-Disposition”是内联的而不是附件?

或者是否有任何其他方法可以在 ASP.Net 网页中显示呈现为内联 PDF 的报告?


我正在使用 Reporting Services 2008

在 ASP.Net 站点中,我使用了对 ReportService2005.asmx 和 ReportExecution2005.asmx 的 Web 引用

最佳答案

我正在做一些非常相似的事情。但我使用的是 HttpWebRequest 而不是使用该服务。这就是我的做法。 重要的部分是 Content-Disposition 中文件名之前的内联

这还取决于他们的 Adob​​e Reader 版本(我们发现他们需要 7 或更高版本)以及他们在其中设置的设置(以防他们将其设置为不在浏览器中打开 PDF)。

HttpResponse currentResponse = HttpContext.Current.Response;
currentResponse.Clear();
currentResponse.ClearHeaders();
currentResponse.ClearContent();

filename = String.Format("{0}.pdf", this.ReportName);
currentResponse.AppendHeader("Content-Disposition", String.Format("inline;filename={0}", filename));
currentResponse.ContentType = "Application/PDF";

//Copy the content of the response to the 
//current response using BinaryWrite
snip....

currentResponse.End();

关于c# - 如何在 ASP.Net 和 C# 网页中将 Reporting Services 报告显示为内联 PDF?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/584609/

相关文章:

c# - App_Code 和服务器

c# - 无尽的滚动asp.net

c# - PDFsharp 看不到文档中的页面

c# - 数字证书无效

c# - telerik radgrid 中的多个编辑列

asp.net - FindControl() 返回 null

c# - 将标题附加到文本文件

c# - 如何在复合模型上应用 Required 属性?

c# - .NET 中的通用线程池

c# - 如何将 .NET 库移动到子目录?