0

i'm trying to get information of a printer. Using WMI i can retrieve some information but only if a job has been sent.

I need to check if my printer is out of paper before sending a job.

Is this possible?

svick
  • 236,525
  • 50
  • 385
  • 514
Alexx Perez
  • 215
  • 2
  • 10
  • 19

3 Answers3

2

I haven't used it myself but have a look here:

http://msdn.microsoft.com/en-us/library/system.printing.printqueue.isoutofpaper.aspx

Daniel
  • 891
  • 6
  • 18
0

check DetectedErrorState property, 3 is low paper, 4 is no paper, 5 is low toner

fuli
  • 1
0

This is how i did it...

   //check PAPER OK and Toner OK
    private static bool IspaperOK(ManagementBaseObject printer)
    {
        bool PaperOK = true;

        string[] printers = ConfigurationManager.AppSettings["ModelliStampanti"].Trim().Split('#');

        foreach (var property in printer.Properties)
        {

            if (property.Name == "DeviceID")
            {
                var PaperStatus = printer.Properties["PrinterState"].Value.ToString();
                for (int i = 0; i <= printers.Length - 1; i++)
                {

                    if (property.Value.ToString() == printers[i].ToString())
                    {     //131072 = Toner Low
                          //1024 = printing
                          //16 = Out of Paper
                          //5 = out of paper
                          //128 - offline(no internet connection)   


                          //this is for out of paper....
                        if ((PaperStatus == "5") ||(PaperStatus == "16"))
                        {
                            PaperOK = false;
                        }

                        //this is for low toner....
                        if (PaperStatus == "131072")
                        {
                            PaperOK = false;
                        }

                    }

                }


            }

        }
        return PaperOK;
    }

To verify these problems use these values instead of values described in MSDN

                //131072 = Toner Low
                //1024 = printing
                //16 = Out of Paper
                //5 = out of paper
                //128 - offline(no internet connection OR printer turned off )
Milan Madubasha
  • 611
  • 5
  • 4