【发布时间】:2017-04-11 03:34:55
【问题描述】:
我在过去两天遇到问题。我正在尝试在没有 reportviewer 的情况下以 pdf 格式查看 rdlc 报告。我使用以下代码将 rdlc 导出为 pdf...
public string Export(LocalReport rpt, string filePath)
{
string ack = "";
try
{
Warning[] warnings;
string[] streamids;
string mimeType;
string encoding;
string extension;
byte[] bytes = rpt.Render("PDF", null, out mimeType, out encoding, out extension, out streamids, out warnings);
using (FileStream stream = File.OpenWrite(filePath))
{
stream.Write(bytes, 0, bytes.Length);
}
return ack;
}
catch(Exception ex)
{
ack = ex.InnerException.Message;
return ack;
}
}
导出到User->AppData->Temp的pdf文件
string filePath = System.IO.Path.GetTempFileName();
string ack = Export(rpt, Server.MapPath("~/Reports/Mymun_Lab/ComparisonStudy.rdlc"));
System.Diagnostics.Process.Start(filePath);
我想将此 pdf 文件渲染到客户端 PC。
此代码在我的本地机器上运行良好。但是当我将它发布到 IIS 服务器并运行时,尝试将导出的 pdf 文件发送到客户端 PC 不成功。我该如何解决这个问题。谁能帮帮我。
提前致谢...
【问题讨论】:
标签: c# asp.net-mvc asp.net-mvc-4 pdf-generation rdlc