Click here to Skip to main content
15,891,943 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi every one,
i am using crystal reports 13 with asp.net. problem is that when i click on print button it exports report in pdf format instead of print it i dont want to do like this just show print dialog or print on print button
thanks!
Posted

below code will print your report to default printer
Hope it will help you


DataSet reg =ViewState["ds"] as DataSet ;
ReportDocument rptDoc = new ReportDocument();
rptDoc.Load(Server.MapPath("stud_registration3.rpt"));
rptDoc.SetDataSource(reg);
foreach (CrystalDecisions.CrystalReports.Engine.Table myTable in rptDoc.Database.Tables)
{
TableLogOnInfo myLogin = myTable.LogOnInfo;
myLogin.ConnectionInfo.IntegratedSecurity = true;
myTable.ApplyLogOnInfo(myLogin);
myTable.ApplyLogOnInfo(myLogin);
}
CrystalReportViewer1.ReportSource = rptDoc;
CrystalReportViewer1.DataBind();
rptDoc.PrintToPrinter(1, true, 0, 0);
 
Share this answer
 
C#
ReportDocument myReportDocument = new ReportDocument();
       myReportDocument.Load(Server.MapPath(@"GL_Report\voucher.rpt"));
       myReportDocument.SetDataSource(ds);
       MemoryStream ms;
       ms = (MemoryStream)myReportDocument.ExportToStream(ExportFormatType.PortableDocFormat);
       Response.Clear();
       Response.Buffer = true;
       Response.ContentType = "application/pdf";
       Response.BinaryWrite(ms.ToArray());
       Response.End();<pre lang="c#">
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900