Default printer setting is changed in windows.

Mar 3 2021 12:50 PM
Hello Team,
The system default print setting will be changing when my customer has used to print a document in my application. Attached the screenshot for the printer setting default screen.
 
I have used the below code to print my documents in my project, I need to use the below code and print my documents without change the system default printer setting.
 
In my project, I will print the image in the below code. Any have an idea please share how to print without change the system default print setting.
  1.     PrintDocument pd = new PrintDocument();  
  2.             PrintController printController = new StandardPrintController();  
  3.             pd.PrintController = printController;  
  4.             pd.PrinterSettings.PrinterName = LabelPrinter.Text.ToString(); //Printer Name  
  5.             pd.PrinterSettings.Copies = Convert.ToInt16(printqty);  
  6.             pd.DefaultPageSettings.Landscape = false;  
  7.             pd.DefaultPageSettings.Margins = new Margins(0, 0, , 0);  
  8.             pd.PrinterSettings.DefaultPageSettings.Margins = new Margins(0, 0, 0, 0);  
  9. pd.PrintPage += (sndr, args) =>  
  10.             {  
  11.                 System.Drawing.Image i = System.Drawing.Image.FromFile(FileName); //image  
  12.   
  13.             //Adjust the size of the image to the page to print the full image without losing any part of the image.  
  14.             System.Drawing.Rectangle m = args.MarginBounds;  
  15.   
  16.             //Logic below maintains the Aspect Ratio.  
  17.             if ((double)i.Width / (double)i.Height > (double)m.Width / (double)m.Height) // image is wider  
  18.                  {  
  19.                         m.Height = (int)((double)i.Height / (double)i.Width * (double)m.Width);  
  20.                  }  
  21.   
  22.                 else  
  23.                  {  
  24.                         m.Width = (int)((double)i.Width / (double)i.Height * (double)m.Height);  
  25.                  }  
  26.   
  27.             //Calculating optimal orientation.  
  28.             pd.DefaultPageSettings.Landscape = m.Width > m.Height;  
  29.                 pd.DefaultPageSettings.Landscape = false;                                                             
  30.             args.Graphics.DrawImage(i, m);  
  31.            };  
  32.            pd.Print();  
 

Answers (6)