How to get a list or number of jobs from a print queue?

I am looking for a way to get a list or number of jobs from a specific printer. At best, I would like to have a “job object” that represents one print job and its name in the print queue. A.

This is necessary because I need to monitor the status of the printer so that I can replenish the print queue with a new batch of documents without overflowing the print queue manager

Thanks in advance!

Edit: added solution code snippet

private int GetNumberOfPrintJobs() { LocalPrintServer server = new LocalPrintServer(); PrintQueueCollection queueCollection = server.GetPrintQueues(); PrintQueue printQueue = null; foreach (PrintQueue pq in queueCollection) { if (pq.FullName == PrinterName) printQueue = pq; } int numberOfJobs = 0; if (printQueue != null) numberOfJobs = printQueue.NumberOfJobs; return numberOfJobs; } 
+8
c # queue printing
source share
2 answers

You can use the .NET 3.0 PrintQueue class in the System.Printing namespace. The NumberOfJobs property indicates how many jobs are queued, GetPrintJobInfoCollection () returns data about all jobs. Remember that there are no events reporting that the collection of tasks has changed, you need to poll the timer. Somehow a second or so should be fine.

+7
source share

you can use WMI to get system information about devices, etc.

see this article

0
source share

All Articles