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


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: