locked
print to a non default printer RRS feed

  • Question

  • User-1602579257 posted

    I am making an asp.net where users supposed to print tags after doing their works. the tags are crystal reports based. I instaled all the printers in the server and i have a method return the nearest available printer to the user. the probleme is unless the printer is set as default printer to the server i have a "no printer are installed" or the tags are simply printed to the default printer not the chosen one. here is my code:

    string printername = getPrinter();
            ReportDocument rd = new ReportDocument();
            rd.PrintOptions.PrinterName = printername;
            rd.Load(Server.MapPath("../GFile/TAG.rpt"));
            rd.PrintOptions.PrinterName = printername;
            rd.SetDataSource(sd);
            int number = int.Parse(tbxNumTaG.Text);
            try
            {
                rd.PrintToPrinter(number, false, 0, 0);
            }
            catch(Exception ex)
            {
                Page.ClientScript.RegisterStartupScript(GetType(), "printer Problems", "alert('" + ex.Message + " " + printername + "Your associated printer not working contact the admin!');", true);
            }



    Monday, August 12, 2013 3:25 AM

Answers

  • User1508394307 posted

    There are some threads that it might happen due to a wrong name of printer. Try to set required printer as default and then check its name 

    e.g. rpt.PrintOptions.PrinterName.ToString()

    and compare with the name you used, or enumerate all printers as shown here

    http://stackoverflow.com/questions/680315/how-to-printing-crystal-report-directly-to-network-printer-in-vb-net-or-c-net-i 

    Another issue might be due to specific version of your setup, check this http://scn.sap.com/thread/2099449 (see post regarding CrystalDecisions.ReportAppServer.ClientDoc.ISCDReportClientDocument)

    Hope this helps.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, August 12, 2013 4:14 AM
  • User-578610739 posted

    Hi Definder,

    rd.PrintToPrinter(number, false, 0, 0);

    Your this code is directly call the default printer , if it is set. Else it throw the error which you handled very well.

    "PrinttoPrinter" is print directly print on default printer.

    So you don't worry about this , this is client setting and you can't change or print on require print on particular printer.

    http://forums.asp.net/t/1651613.aspx/1

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, August 12, 2013 4:18 AM

All replies

  • User1508394307 posted

    There are some threads that it might happen due to a wrong name of printer. Try to set required printer as default and then check its name 

    e.g. rpt.PrintOptions.PrinterName.ToString()

    and compare with the name you used, or enumerate all printers as shown here

    http://stackoverflow.com/questions/680315/how-to-printing-crystal-report-directly-to-network-printer-in-vb-net-or-c-net-i 

    Another issue might be due to specific version of your setup, check this http://scn.sap.com/thread/2099449 (see post regarding CrystalDecisions.ReportAppServer.ClientDoc.ISCDReportClientDocument)

    Hope this helps.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, August 12, 2013 4:14 AM
  • User-578610739 posted

    Hi Definder,

    rd.PrintToPrinter(number, false, 0, 0);

    Your this code is directly call the default printer , if it is set. Else it throw the error which you handled very well.

    "PrinttoPrinter" is print directly print on default printer.

    So you don't worry about this , this is client setting and you can't change or print on require print on particular printer.

    http://forums.asp.net/t/1651613.aspx/1

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, August 12, 2013 4:18 AM