FastReport ASP.Net开发Web报表时直接打印的问题


这个问题官网一直都没有解决,反复强调说只有转成PDF才是最好的结局方法,官方给出了个半自动的解决方案,各位可以参考一下。

protected void Button1_Click(object sender, EventArgs e)
 {
     FastReport.Utils.Config.WebMode = true;
 
     using (Report report = new Report())
     {
  report.Load("your_report.frx");
  report.RegisterData(...);
  report.Prepare();
 
  // Export report to PDF stream
  FastReport.Export.Pdf.PDFExport pdfExport = new FastReport.Export.Pdf.PDFExport();
  using (MemoryStream strm = new MemoryStream())
  {
      report.Export(pdfExport, strm);
 
      // Stream the PDF back to the client as an attachment
      Response.ClearContent();
      Response.ClearHeaders();
      Response.Buffer = true;
      Response.ContentType = "Application/PDF";
      Response.AddHeader("Content-Disposition", "attachment;filename=report.pdf");
 
      strm.Position = 0;
      strm.WriteTo(Response.OutputStream);
      Response.End();
  }
 
     }
 }

FastReport ASP.Net包括在FastReport.Net里面,有兴趣的可以点这里下载~

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM