How to monitor the current status of the printer In WPF?

929Free 281 Reputation points
2020-06-23T04:47:36.647+00:00

When I print a document, I have no paper, this time, I want to get finished or paperless status? Thanks

Windows Presentation Foundation
Windows Presentation Foundation
A part of the .NET Framework that provides a unified programming model for building line-of-business desktop applications on Windows.
2,686 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. DaisyTian-1203 11,616 Reputation points
    2020-06-23T06:05:58.123+00:00

    You can use the below code which use PrintQueue to get the status PrintQueueStatus of printer:

    public static void GetPrintStatus()  
            {  
                PrintQueue pq = LocalPrintServer.GetDefaultPrintQueue();  
                switch (pq.QueueStatus)  
                {  
                    case PrintQueueStatus.None:  
                        Console.WriteLine("Status is not specified");  
                        break;  
                    case PrintQueueStatus.OutputBinFull:  
                        Console.WriteLine("The printer's output bin is full");  
                        break;  
                    case PrintQueueStatus.PaperOut:  
                        Console.WriteLine("The printer does not have, or is out of, the type of paper needed for the current print job");  
                        break;  
                    case PrintQueueStatus.Printing:  
                        Console.WriteLine("Printer is printing");  
                        break;  
                    default:  
                        Console.WriteLine(pq.QueueStatus);  
                        break;  
                }  
            }