I need to get the default printer name. I'll be using C# but I suspect this is more of a framework question and isn't language specific.
InteropServices; Step 3: Use the following function to set desired printer as default printer. PrinterClass. SetDefaultPrinter("Paste your desired Printer Name here");
The easiest way I found is to create a new PrinterSettings
object. It starts with all default values, so you can check its Name property to get the name of the default printer.
PrinterSettings
is in System.Drawing.dll in the namespace System.Drawing.Printing
.
PrinterSettings settings = new PrinterSettings(); Console.WriteLine(settings.PrinterName);
Alternatively, you could maybe use the static PrinterSettings.InstalledPrinters
method to get a list of all printer names, then set the PrinterName property and check the IsDefaultPrinter. I haven't tried this, but the documentation seems to suggest it won't work. Apparently IsDefaultPrinter is only true when PrinterName is not explicitly set.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With