How to receive data from the printer(HP LaserJet Pro M305d); for example Load Paper, In windows form Application .Net 4.5 C#

30 Views Asked by At

as i said i am developing windows form application using .Net 4.5 C#, Now i want to receive info about the printer status, i used one of the way i found, here is it:

 private bool IsPrinterPaperAvailable()
    {
        // Get the default printer
        PrintDocument printDocument = new PrintDocument();
        string defaultPrinterName = printDocument.PrinterSettings.PrinterName;

        // Create a PrintServer object to manage the printer queue
        using (PrintServer printServer = new PrintServer())
        {
            // Get the printer queue for the default printer
            PrintQueue printQueue = new PrintQueue(new PrintServer(), defaultPrinterName);
            
            printQueue.Refresh();

            // Check if the printer queue has paper
            if (printQueue.IsOutOfPaper)
            {
                return false;
            }
        }

        return true;
    }

this expression: printQueue.IsOutOfPaper is always returning false and all of the other option that printQueue Offers, i think the problem is not from my code, i think the problem is i am not sending or letting the printer send the printer status, is there a specific drive i have to install. ps: even in when i open the printer from windows it is giving me this status: 0 document in queues, i hope you guys can help me out, i am trying to solve this issue for like a week.

0

There are 0 best solutions below