I have checked with the "Let \Windows manage my default Printer" checkbox in Printer & Scanners setting, if I used the below code for printing my document, it is changing the default printer from Printer & Scanners setting.
- public void Print(string FileName, int pintprintqty)
- {
- if (string.IsNullOrWhiteSpace(FileName)) return;
- PrintDocument pd = new PrintDocument();
-
- PrintController printController = new StandardPrintController();
- pd.PrintController = printController;
- pd.PrinterSettings.PrinterName = cmbLabelPrinter.Text.ToString();
- pd.PrinterSettings.Copies = Convert.ToInt16(pintprintqty);
- pd.DefaultPageSettings.Landscape = false;
- pd.DefaultPageSettings.Margins = new Margins(0, 0, 0, 0);
- pd.PrinterSettings.DefaultPageSettings.Margins = new Margins(0, 0, 0, 0);
- pd.PrintPage += (sndr, args) =>
- {
- System.Drawing.Image i = System.Drawing.Image.FromFile(FileName);
-
- System.Drawing.Rectangle m = args.MarginBounds;
-
- if ((double)i.Width / (double)i.Height > (double)m.Width / (double)m.Height)
- {
- m.Height = (int)((double)i.Height / (double)i.Width * (double)m.Width);
- }
- else
- {
- m.Width = (int)((double)i.Width / (double)i.Height * (double)m.Height);
- }
-
- pd.DefaultPageSettings.Landscape = m.Width > m.Height;
- pd.DefaultPageSettings.Landscape = false;
- args.Graphics.DrawImage(i, m);
- };
- pd.Print();
- }
How to print the document without changing the default printer setting in "Let Windows manage my default Printer" checkbox checked mode?