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?
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?
I haven't used it myself but have a look here:
http://msdn.microsoft.com/en-us/library/system.printing.printqueue.isoutofpaper.aspx
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 )