Get the printer settings
Description :
We can get the printer settings and display it.
For example we can get the "Supported Paper Sizes"
Following code is used to get Supported Paper Sizes of the printer installed in the system
Name spaces
using System;
using System.Drawing.Printing;
Code Segment
class MainClass {
static void Main(string[] args) {
foreach (string MyprinterName in PrinterSettings.InstalledPrinters) {
Console.WriteLine("Printer: {0}", MyprinterName);
PrinterSettings Myprinter = new PrinterSettings();
Myprinter.PrinterName = MyprinterName;
if (Myprinter.IsValid) {
Console.WriteLine("Supported Paper Sizes:");
foreach (PaperSize size in Myprinter.PaperSizes) {
if (Enum.IsDefined(size.Kind.GetType(), size.Kind)) {
Console.WriteLine(" {0}", size);
}
}
}
}
}
}
Code Explanation
1. parsing the InstalledPrinters in the PrinterSettings
2. check whether the valid printer
3. parsing the Papersizes in the found printer
4. Print the paper size
By
Nathan
