0
votes

I have created a report in crystal report and my problem is that my code is not making picking windows default printer don't know y.here is my printers. Application at the point of printing is picking the pdf printer but have set the highlighted printer as default

And here is my code to print the report

MyCrystalReport rep=new MyCrystalReport();
            
            rep.SetParameterValue("cash_tendered", "100");
            rep.SetParameterValue("change", "50");
            rep.SetParameterValue("pay_mode","Cash");
            try
            {


                rep.PrintToPrinter(1, false, 0, 0);

            }
            catch (Exception ex)
            {
                AppUtil.showErrorBox("Printer Error!!\n" + ex.Message);
            }
2
In your Crystal Report designer, go to Page Setup. What settings do you have for the Printer Options section? Have you tried setting it to the correct printer here, or have you tried checking the box for "No Printer (optimize for display)"?R. McMillan
@R.McMillan thanks alot for your idea. The problem was on the crystal report set up. I had set up the printer to have pdf printerMorgan Denis
Glad to help. I added a proper answer for posterity's sake since this seems to have resolved your issue.R. McMillan

2 Answers

1
votes

In your report designer go into Page Setup and check the Printer Options section. It should be set to either the printer you want to use for the report, or check the check box for "No Printer".

1
votes

You can use PrinterName Property to achieve this.

    var dialog= new PrintDialog();
    rep.PrintOptions.PrinterName = dialog.PrinterSettings.PrinterName;
    rep.PrintToPrinter(1, false, 0, 0);