如何在不导出到磁盘的情况下在新选项卡上预览 PDF 格式 Crystal 报告

How to get preview of PDF Formatted Crystal Report on New Tab without Exporting to disk

我正在一个网站上工作,现在生成的收据直接在指定路径上 ExportedToDisk

这是 Crystal 报告 ExportToDisk

的工作代码
filename = "BillRCPT.pdf";
ReportDocument crystalReport = new ReportDocument(); // creating object of crystal report
crystalReport.Load(Server.MapPath(ReportPath)); // path of report
crystalReport.SetDataSource(datatable); // binding datatable
try
{
    crystalReport.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, filename);
    crystalReport.Dispose();
}
catch (Exception ex)
{
    crystalReport.Dispose();
    log.WriteFile(GetType().Name, System.Reflection.MethodBase.GetCurrentMethod().Name, ex.StackTrace, ex.Source, ex.Message, (ex.StackTrace.Substring(ex.StackTrace.LastIndexOf(' '))).ToString());
}

在存储 PDF 之前我想预览 Crystal 报告,所以那时我会直接打印收据或下载它...

可能吗?如果是,那我该如何实现...

我用谷歌搜索了这个但没能找到预期的结果...

这可能是重复的问题...如果是那么请建议...

谢谢

如果您使用的是 Web 表单,请创建一个新的表单/控件,它的唯一内容应该是 CrystalDecisions.Web 程序集注册和这个

<CR:CrystalReportViewer ID="CRep" runat="server" AutoDataBind="False" Height="600px"  Width="900px" HasCrystalLogo="False" HasDrillUpButton="False" HasSearchButton="False" HasToggleGroupTreeButton="False" /> 

并且在你后面的代码中

ExportFormatType type = ExportFormatType.PortableDocFormat;
crystalReport.ExportToHttpResponse(ExportFormatType.PortableDocFormat, Response, false, "Report name");`