I am working on a website, right now generated Receipt get directly ExportedToDisk on specified path.
this is working Code for Crystal Report 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());
}
Before storing PDF I wanted a preview of Crystal Report, so at that time I will either directly print the Receipt or Download it...
Is it possible? if yes then how can I achieve it...
I googled this but not able to find expected outcome...
It may be duplicate question... if it is then Please suggest...
Thank You
If you are using web forms, create a new form/ control and the only content of it should be CrystalDecisions.Web
assembly registration and this
<CR:CrystalReportViewer ID="CRep" runat="server" AutoDataBind="False" Height="600px" Width="900px" HasCrystalLogo="False" HasDrillUpButton="False" HasSearchButton="False" HasToggleGroupTreeButton="False" />
And in your code behind
ExportFormatType type = ExportFormatType.PortableDocFormat;
crystalReport.ExportToHttpResponse(ExportFormatType.PortableDocFormat, Response, false, "Report name");`