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