Information about the printers


We can get all the information about the printers which are installed in your computer.

Following is the code to get all the printer name and their some
attribute.




using System;
using System.Drawing.Printing;

class MyPrinterClass {
static void Main(string[] args) {

foreach (string MyPrinterName in PrinterSettings.InstalledPrinters)
{
Console.WriteLine("Printer Name : ", MyPrinterName);

PrinterSettings MyPrinter = new PrinterSettings();
MyPrinter.PrinterName = MyPrinterName;

if (MyPrinter.IsValid) {
Console.WriteLine("Paper Sizes Supported by the printer " + MyPrinterName );

foreach (PaperSize MyPaperSize in MyPrinterr.PaperSizes) {
if (Enum.IsDefined(MyPaperSize.Kind.GetType(), MyPaperSize.Kind)) {
Console.WriteLine(" {0}", MyPaperSize);
}
}
}
}
}
}




Way to achive

1. Get all the printers using the foreach loop which are installed in the computers
2. Create the instace of the printer using the class PrinterSettings
3. Get some attribute by using foreach.
4. The above code will display some sample paper size of the printer
5. You can also get many information about your printer

By
Nathan


Comments

No responses found. Be the first to comment...


  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:
    Email: