Multi Printer Support Program in ASP.Net C#

I have made this program for one of my client,who want to give one print command to print a document on different printers in different location simultaneously which are connected to server. RPC should be activated on server to use this program.
  1. string FilePath = strPathToUpload + "\\" + fUpload.FileName;  
  2. if (strExt.ToUpper().Equals("TXT"))  
  3. {  
  4.     fUpload.SaveAs(strPathToUpload + "\\" + fUpload.FileName);   
  5.     Printer1(FilePath);  
  6.     Printer2(FilePath);  
  7. }  
  8. else  
  9. {  
  10.     lblMessage.Text="Invalid File Seleected";  
  11. }  
  12. public void Printer1(string FilePath)  
  13. {  
  14.     sr = new StreamReader(FilePath);  
  15.     f = new Font("Courier New", 14);  
  16.     PrintDocument pd = new PrintDocument();
  17.     pd.PrintPage += new PrintPageEventHandler(pqr);  
  18.     pd.PrinterSettings.PrinterName = "PDF995";  
  19.     if (pd.PrinterSettings.IsValid)  
  20.     {  
  21.        pd.Print();  
  22.     }  
  23.     sr.Close();  
  24. }  
  25. public void Printer2(string FilePath)  
  26. {  
  27.     sr = new StreamReader(FilePath);  
  28.     f = new Font("Courier New", 14);   
  29.     PrintDocument pd2 = new PrintDocument();   
  30.     pd2.PrintPage += new PrintPageEventHandler(pqr);   
  31.     pd2.PrinterSettings.PrinterName = "Real PDF Printer";   
  32.     if (pd2.PrinterSettings.IsValid)  
  33.     {  
  34.         pd2.Print();  
  35.     }  
  36.     sr.Close();
  37. }  
  38. void pqr(object o, PrintPageEventArgs e)  
  39. {  
  40.     float lpp = e.MarginBounds.Height / f.GetHeight(e.Graphics);  
  41.     int c = 0;  
  42.     String s = null;  
  43.     while (c < lpp && ((s = sr.ReadLine()) != null))  
  44.     {  
  45.        float y = e.MarginBounds.Top + (c * f.GetHeight(e.Graphics));  
  46.        e.Graphics.DrawString(s, f, Brushes.Black, e.MarginBounds.Left, y);  
  47.        c++;  
  48.     }  
  49.     if (s != null)  
  50.     e.HasMorePages = true;
  51.    else  
  52.      e.HasMorePages = false;  
  53. }  
Ebook Download
View all
Learn
View all