RDLC生成PDF

时间:2015-04-15 16:17:03

标签: javascript c# angularjs

我正在寻找指导或想法,通过RDLC报告生成PDF而不使用reportviewer。 PDF必须保存在本地指定的路径中。我已经尝试了一周,但我仍然无法找到解决方案。

1 个答案:

答案 0 :(得分:0)

希望此链接有所帮助 RDLC to PDF

这就是为了完整性而渲染为pdf ...的方法

private void CreatePDF(string fileName)
{
    // Variables
    Warning[] warnings;
    string[] streamIds;
    string mimeType = string.Empty;
    string encoding = string.Empty;
    string extension = string.Empty;


    // Setup the report viewer object and get the array of bytes
    ReportViewer viewer = new ReportViewer();
    viewer.ProcessingMode = ProcessingMode.Local;
    viewer.LocalReport.ReportPath = "YourReportHere.rdlc";


    byte[] bytes = viewer.LocalReport.Render("PDF", null, out mimeType, out encoding, out extension, out streamIds, out warnings);


    // Now that you have all the bytes representing the PDF report, buffer it and send it to the client.
    Response.Buffer = true;
    Response.Clear();
    Response.ContentType = mimeType;
    Response.AddHeader("content-disposition", "attachment; filename=" + fileName + "." + extension);
    Response.BinaryWrite(bytes); // create the file
    Response.Flush(); // send it to the client to download
}