【发布时间】:2015-09-02 18:48:59
【问题描述】:
我有一个“下载 PDF”按钮,它呈现 ReportViewer 并使用 Adobe Reader 在浏览器中打开它。
代码如下:
Warning[] warn = null;
String[] streamids = null;
String mimeType = "application/pdf";
String encoding = String.Empty;
String extension = String.Empty;
Byte[] byteViewer;
byteViewer = report.LocalReport.Render("pdf", null, out mimeType, out encoding, out extension, out streamids, out warn);
Response.Buffer = true;
Response.Clear();
Response.ContentType = "application/pdf";
Response.AddHeader("content-disposition", "inline; filename=" + fileName + ".pdf");
Response.BinaryWrite(byteViewer);
Response.Flush();
Response.End();
但是现在,我不想打开 pdf,而是想打开一个下载对话框来下载文件。我应该对代码进行哪些更改?
@编辑 该问题的答案太广泛了,我的问题是为了简化下载 ReportViewer 的过程,并为未来可能遇到此问题的 C# 程序员添加参考,而无需挖掘无用的 php 代码行来查找答案。
【问题讨论】:
-
那个骗子是针对php的,但是php是无关紧要的。标题很重要。
-
你在那个问题中看到有很多行“标题”代码,如果你能简单地说哪一个解决了我的问题,那就太好了......
-
没关系,找到了。
标签: c# pdf crystal-reports