mary

mary

  • NA
  • 5
  • 0

How i can check printer status before sending a job ?

Aug 12 2011 2:29 PM
Hello.
I write following code for get printer status in constructor class.my printers are turn on but are no paper or low toner or etc.
i want get errors for low paper or no paper or no toner and etc runtime.

<pre lang="c#">
class PrinterStatus
  {

  public PrinterStatus()
  {
  String statusReport = "";
  PrintServer myPS = new PrintServer();
  PrintQueueCollection myPrintQueues = myPS.GetPrintQueues();
  foreach (PrintQueue pq in myPrintQueues)
  {
  pq.Refresh();
  {
  statusReport = pq.Name;
  if ((pq.QueueStatus & PrintQueueStatus.PaperProblem) == PrintQueueStatus.PaperProblem)
  {
  statusReport = statusReport + "Has a paper problem. ";
  }
  if ((pq.QueueStatus & PrintQueueStatus.NoToner) == PrintQueueStatus.NoToner)
  {
  statusReport = statusReport + "Is out of toner. ";
  }
  if ((pq.QueueStatus & PrintQueueStatus.DoorOpen) == PrintQueueStatus.DoorOpen)
  {
  statusReport = statusReport + "Has an open door. ";
  }
  if ((pq.QueueStatus & PrintQueueStatus.Error) == PrintQueueStatus.Error)
  {
  statusReport = statusReport + "Is in an error state. ";
  }
  if ((pq.QueueStatus & PrintQueueStatus.NotAvailable) == PrintQueueStatus.NotAvailable)
  {
  statusReport = statusReport + "Is not available. ";
  }
  if ((pq.QueueStatus & PrintQueueStatus.Offline) == PrintQueueStatus.Offline)
  {
  statusReport = statusReport + "Is off line. ";
  }
  if ((pq.QueueStatus & PrintQueueStatus.OutOfMemory) == PrintQueueStatus.OutOfMemory)
  {
  statusReport = statusReport + "Is out of memory. ";
  }
  if ((pq.QueueStatus & PrintQueueStatus.PaperOut) == PrintQueueStatus.PaperOut)
  {
  statusReport = statusReport + "Is out of paper. ";
  }
  if ((pq.QueueStatus & PrintQueueStatus.OutputBinFull) == PrintQueueStatus.OutputBinFull)
  {
  statusReport = statusReport + "Has a full output bin. ";
  }
  if ((pq.QueueStatus & PrintQueueStatus.PaperJam) == PrintQueueStatus.PaperJam)
  {
  statusReport = statusReport + "Has a paper jam. ";
  }
  if ((pq.QueueStatus & PrintQueueStatus.Paused) == PrintQueueStatus.Paused)
  {
  statusReport = statusReport + "Is paused. ";
  }
  if ((pq.QueueStatus & PrintQueueStatus.TonerLow) == PrintQueueStatus.TonerLow)
  {
  statusReport = statusReport + "Is low on toner. ";
  }
  if ((pq.QueueStatus & PrintQueueStatus.UserIntervention) == PrintQueueStatus.UserIntervention)
  {
  statusReport = statusReport + "Needs user intervention. ";
  }
  }
  }// end for each print queue
  }
  }

</pre>

but at runtime Isoutofpaper and paperproblem properties and etc are false.
Thanks.

Answers (1)