title: Is there a way to check if a printing process was successful?
body: <p>I have an application where I need to print a ticket. Each ticket must be unique. The application is windows forms and written entirely in c#. For our application we're using Samsung ML- 2525 laser monochromatic printers. </p>
  
  <p>The flow is basically the following, the operator picks a product/ticket (which is unique) and then it presses a button that does 2 things:</p>
  
  <ol>
  <li>Connects to a database and updates the product as used</li>
  <li>Prints the ticket (this is done using System.Drawing and GDI+)</li>
  </ol>
  
  <p>For some reason, every once in a while, the image that needs to be printed is not sent to the printer. It's a rare case, but it happens. </p>
  
  <p>I tried to connect to the printer using Win32_Printer ( <a href="http://msdn.microsoft.com/en-us/library/Aa394363" rel="noreferrer">http://msdn.microsoft.com/en-us/library/Aa394363</a> ) but I can't get to get the current printer's state (online, offline, low toner, paper jam, etc). I can only check if the printer exists and that the paper size is installed correctly. I tried code similar to the following but it didn't work</p>
  
  <pre><code>    private string MonitorPrintJobWmi()
      {
          var jobMessage = String.Empty;
          var scope = new ManagementScope(ManagementPath.DefaultPath);
          scope.Connect();
  
          var selectQuery = new SelectQuery { QueryString = @"select *  from Win32_PrintJob" };
  
          var objSearcher = new ManagementObjectSearcher(scope, selectQuery);
          var objCollection = objSearcher.Get();
  
          foreach (var job in objCollection)
          {
              if (job != null)
              {
                  jobMessage += String.Format("{0} \r\n", job["Name"].ToString());
                  jobMessage += String.Format("{0} \r\n", job["JobId"].ToString());
                  _jobId = Convert.ToInt32(job["JobId"]);
                  jobMessage += String.Format("{0} \r\n", job["JobStatus"].ToString());
                  jobMessage += String.Format("{0} \r\n", job["Status"].ToString());
              }
          }
          return jobMessage;
      }
  </code></pre>
  
  <p>I tried to get an API for the printer but I couldn't get a hold of it. By the way, the printer's software do indicate different errors in the windows toolbar.</p>
  
  <p>My question is if anyone can lead me in the right direction as to how to connect to a printer and check if printing was successful.</p>
  
  <p>Also, it would be helpful if someone know of some other specific printer in which I may accomplish this ie, changing hardware. </p>
  
  <p>Thanks,</p>