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
