简体   繁体   English

如何在 ASP.Net 和 C# web 页面中将 Reporting Services 报表显示为内联 PDF?

[英]How to display a Reporting Services report as an inline PDF, in a ASP.Net and C# web page?

I need to display a preview of a report, in an ASP.Net web page (using C# server side scripts).我需要在 ASP.Net web 页面中显示报告的预览(使用 C# 服务器端脚本)。 The preview needs to be a PDF rather than HTML and displayed inline (possibly in an iframe?).预览需要是 PDF 而不是 HTML 并内联显示(可能在 iframe 中?)。

Is it possible to specify the headers of a report rendered as a PDF, so its 'Content-Disposition' is inline rather than attachment?是否可以指定呈现为 PDF 的报告的标题,因此它的“内容处置”是内联而不是附件?

Or is there any other way to display a report rendered as a PDF inline in an ASP.Net web page?或者有没有其他方法可以在 ASP.Net web 页面中显示呈现为 PDF 内联的报表?


I am using Reporting Services 2008我正在使用 Reporting Services 2008

In the ASP.Net site I am using web references to ReportService2005.asmx and ReportExecution2005.asmx在 ASP.Net 站点中,我使用 web 对 ReportService2005.asmx 和 ReportExecution2005.asmx 的引用

I'm doing something that is very similar.我正在做一些非常相似的事情。 But I'm using a HttpWebRequest instead of using the service.但我使用的是 HttpWebRequest 而不是使用该服务。 Here's how I'm doing it.这就是我的做法。 The important part is the inline before the file name in the Content-Disposition .重要的部分是 Content-Disposition 中文件名之前的内联

It also depends on their version of Adobe Reader (we found they need 7 or upwards) and the settings they have set inside it (in case they've set it to not open PDFs inside the browser).这还取决于他们的 Adobe 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();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM