This code when i want to get all my system printer list and set the default printer in my application while i used this code its working good. because of i want to do bar code printer so i have used more then one printer. Its very easy to get the system printer name using this method.

using System.Text;
using System.Windows.Forms;
using System.Management;
using System.Drawing.Printing;

namespace GetPrintersName
{
    public partial class Form1 : Form
    {
        public Form1()
        {           
            InitializeComponent();
        }
    }

    private void Form1_Load(object sender, EventArgs e)
    {
        printer();
    }

    public static void printer() 
    {
        foreach (string printer in PrinterSettings.InstalledPrinters)
                 Console.WriteLine(printer);
 
            var printerSettings = new PrinterSettings();
            Console.WriteLine(string.Format("The default printer is: {0}",                         printerSettings.PrinterName));                 
     }
}

0 comments

Related Posts Plugin for WordPress, Blogger...