Thursday, June 2, 2016

To get the default printer in C#

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);

Reference:

http://stackoverflow.com/questions/86138/whats-the-best-way-to-get-the-default-printer-in-net

No comments: