Akhter HUssain

Akhter HUssain

  • 685
  • 1.3k
  • 95.5k

Print on client side default print.

Sep 17 2019 12:21 AM
i am using below code for printing multiple copies directly without preview,after publishing this code ,it is not printing on client default printer ,and throughing print on server printer instead of client print, here is my code please guide..i want to print label on client default printer.
 
  1. protected void btnprnt_Click(object sender, EventArgs e)  
  2.        {  
  3.            if (Convert.ToInt32(txtqty.Text) > 0)  
  4.            {  
  5.                try  
  6.                {  
  7.                    con.Open();  
  8.                    SqlCommand cmd = new SqlCommand("sp_Importlabelprint", con);  
  9.                    cmd.CommandType = CommandType.StoredProcedure;  
  10.   
  11.                    SqlDataAdapter da = new SqlDataAdapter(cmd);  
  12.                    DataSet ds = new DataSet();  
  13.                    da.Fill(ds);  
  14.                    //SqlDataAdapter adp = new SqlDataAdapter("select prdno,orderno,Codeitem,prdqty from probale", con);  
  15.                    //DataSet ds = new DataSet();  
  16.                    //adp.Fill(ds);  
  17.   
  18.                    for (int i = 0; i < Convert.ToInt32(txtqty.Text); i++)  
  19.                    {  
  20.                        ReportDocument rpt = new ReportDocument();  
  21.                        rpt.FileName = Server.MapPath("~/Importlbprint.rpt");  
  22.                        rpt.SetDataSource(ds.Tables["Table"]); //DS is Dataset which you want to print  
  23.                        
  24.                        rpt.SetParameterValue("PageNo", i + 1);  
  25.                        rpt.SetParameterValue("TotalPage", Convert.ToInt32(txtqty.Text));  
  26.                        rpt.PrintToPrinter(1, false, 1, 1);  
  27.                    }  
  28.                      string url = "/lbimportprints.aspx?noc=" + txtqty.Text;  
  29.                       Page.ClientScript.RegisterStartupScript(  
  30.                    this.GetType(), "OpenWindow""window.open('"+url+"','_newtab');"true);  
  31.   
  32.                }  
  33.   
  34.                catch (Exception ex) { }  
  35.   
  36.            }  
  37.        }  
  38.    }  
 

Answers (2)