Display the printer settings

Description :


We can get the printer settings by using the following code part

Namespace part

using System;
using System.Drawing.Printing;



Coding part

namespace MyNameSpace
{
public class MyPrinterSettings
{
[STAThread]
static void Main(string[] args)
{
PrintDocument MyPrintDocument = new PrintDocument();
PageSettings MyPageSettings = MyPrintDocument.DefaultPageSettings;
PrinterSettings MyPrinterSettings = MyPageSettings.PrinterSettings;

Console.WriteLine("My Printer Settings");
Console.WriteLine("PrinterName = " + MyPrinterSettings.PrinterSettings.PrinterName);
Console.WriteLine("Is default Printer = " +
MyPrinterSettings.IsDefaultPrinter.ToString());
Console.WriteLine("Num of copies = " + MyPrinterSettings.Copies.ToString());
Console.WriteLine("Max noof Copies = " + MyPrinterSettings.MaximumCopies.ToString());
Console.WriteLine("Max no of Page = " + MyPrinterSettings.MaximumPage.ToString());
Console.WriteLine("Min no of Page = " + MyPrinterSettings.MinimumPage.ToString());
Console.WriteLine("Supporting Color = " + MyPrinterSettings.SupportsColor.ToString());
foreach (PaperSize psize in MyPrinterSettings.PaperSizes)
Console.WriteLine("Supporting Paper Size: " + psize.PaperName);

Console.WriteLine("Page Settings");

Console.WriteLine("Top Bound = " + MyPageSettings.Bounds.Top.ToString());
Console.WriteLine("Bottom Bound = " + MyPageSettings.Bounds.Bottom.ToString());
Console.WriteLine("Left Bound = " + MyPageSettings.Bounds.Left.ToString());
Console.WriteLine("Right Bound = " + MyPageSettings.Bounds.Right.ToString());
Console.WriteLine("Top Margin = " + MyPageSettings.Margins.Top.ToString());
Console.WriteLine("Bottom Margin = " + MyPageSettings.Margins.Bottom.ToString());
Console.WriteLine("Left Margin = " + MyPageSettings.Margins.Left.ToString());
Console.WriteLine("Right Margin = " + MyPageSettings.Margins.Right.ToString());
Console.WriteLine("PaperSize = " + MyPageSettings.PaperSize.PaperName);

Console.ReadLine();

}
}
}


Code Explanation

1. Create the instance of PrintDocument
2. Create the instance of PageSettings
3. Create the instance of PrinterSettings
4. Get the Printer settings
5. Get the page settings

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: