Click here to Skip to main content
15,886,919 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am new to Crystal Reports.I have developed a report using VisualStudio2017 and every thing is working fine.

My requirement is,i create new button in my application Form and when i click this button crystalreportviewer toolbar the report should send to the default printer on the machine

without showing the print dialog.
i'm using c# winform application.
Any one give me idea how can i do this

What I have tried:

i have no idea how can i do this.
Posted
Updated 21-Jan-19 18:14pm

ReportDocument rd= new ReportDocument
rd.PrintToPrinter(1, false, 0, 0);
 
Share this answer
 
Comments
Fahid Zahoor 21-Jan-19 8:14am    
i use this but it show error message
CrystalDecisions.CrystalReports.Engine.LoadSaveReportException: 'Invalid report file path.'
Fahid Zahoor 21-Jan-19 8:20am    
i have one crystal report named as CustomerCashRecipet.rpt and i use one crystal report viewer named as crystalReportViewer and i also use one crystalreportDocument i load CustomerCashRecipet report to crystalreportDocument and then i display the crystalreportDocument in my report viewer and then take print please tell me something how can i take directly print of crystalreportDocument using button click
Follow these steps
create a new form (To view Crystal Report)
add crystalreportviewer tool to that form


add below libraries
using CrystalDecisions.Shared;
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.ReportSource;


then call the below function in main form's button click

public void bill_Printing()
{
try
{
                DataSet ds_Bill = invoice.Print_Bill();

                ReportDocument rd = new ReportDocument();
                rd.Load(Application.StartupPath + "\\Crystal_Report\\crptBill.rpt");////put your crystal report path here
                rd.Database.Tables[0].SetDataSource(ds_Bill.Tables[0]);

                rd.SetParameterValue("@company", Company);////add parameters if any                            

               
                rd.PrintToPrinter(1, false, 0, 0);
               
            }
            catch (Exception)
            { }
}
 
Share this answer
 
v2
Comments
Fahid Zahoor 24-Jan-19 12:21pm    
your method is good please tell me how can i set default printer so, print directly goes to default printer

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