显示 Reporting Services 中的 PDF
我想在我的 WinForms 应用程序中显示由 Reporting Services 生成的 PDF。
我尝试了以下操作:
Uri uri = new Uri("http://myReportServer?MyReport&rs%3aCommand=Render&rs:Format=pdf");
System.Diagnostics.Process.Start(uri.ToString());
这会启动浏览器,然后浏览器会提示我打开或保存此文件。
理想情况下,我只想在浏览器或 PDF 查看器中显示文件。问题是我必须同时打开浏览器和 PDF 查看器,这是用户不想要的。
有没有一种简单的方法可以仅使用 URL 来完成此操作?
我的另一个选择是只编写一些看起来很简单的 C# 代码。这里有一些示例:
http://geekswithblogs.net/bsherwin/archive /2007/04/29/112094.aspx
和此处:
http: //www.codeproject.com/KB/reporting-services/PDFUsingSQLRepServices.aspx
I would like to display a PDF generated from Reporting Services from my WinForms app.
I tried the following:
Uri uri = new Uri("http://myReportServer?MyReport&rs%3aCommand=Render&rs:Format=pdf");
System.Diagnostics.Process.Start(uri.ToString());
Which launches a browser, which then in turn prompts me to open or save this file.
Ideally I would like to display only the file, either in the browser or in a PDF viewer. Problem is I have to open both the browser and then PDF viewer, which the users doesn't want.
Is there a simple way to do this using just the URL?
My other alternative is to just write some C# code which seems straight forward. There are some examples here:
http://geekswithblogs.net/bsherwin/archive/2007/04/29/112094.aspx
and here:
http://www.codeproject.com/KB/reporting-services/PDFUsingSQLRepServices.aspx
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以将 PDF 下载到磁盘,然后使用 Process.Start 显示它。
看一下这个示例:
更新:
如果默认情况下不起作用,请尝试在 wcli.DownloadFile() 之前添加此内容:
You can download PDF to disk and then use Process.Start to show it.
Take a look at this example:
UPDATE:
If that does not work by default, try to add this before wcli.DownloadFile():