How to get Print Job Status using C#

I am able to print a document, but I do not know how to get its status. I went through many resources (MSDN, Links for checking Job Status), but was not able to find an answer.

I actually want to get confirmation from the printer whether the document was successfully printed or not. Moreover, I am also interested if I can get error signal from printer, like if paper is jammed.

I have the Printer Name and Document name which I am sending for Print. Has anybody done some research in this area and can tell me how to accomplish this?

You might be able to use WMI for this. It provides several printing-related classes, including Win32_PrintJob.

This is untested, but something like this should get you started:

SelectQuery query = new SelectQuery("Win32_PrintJob");

using (ManagementObjectSearcher searcher = new ManagementObjectSearcher(query))
using (ManagementObjectCollection printJobs = searcher.Get())
    foreach (ManagementObject printJob in printJobs)
    {
        // The format of the Win32_PrintJob.Name property is "PrinterName,JobNumber"
        string name = (string) printJob["Name"];
        string[] nameParts = name.Split(',');
        string printerName = nameParts[0];
        string jobNumber = nameParts[1];
        string document = (string) printJob["Document"];
        string jobStatus = (string) printJob["JobStatus"];

        // Process job properties...
    }

PrintSystemJobInfo.JobStatus Property (System.Printing), This may help: MSDN - HOW TO: Determine Printer Status and Print Job Status from Visual Basic[^] It's VB rather than C# but the principles will� Gets the current status of the print job. public: property System::Printing::PrintJobStatus JobStatus { System::Printing::PrintJobStatus get (); }; C#. public System.Printing.PrintJobStatus JobStatus { get; }

there are samples online... google "sending PJL commands in c#" (PJL stands for printer job language)

codeproject Reading Data Directly from the Printer is a nice article/sample to start with

How to get printing status in C#, monitor the print queue for job changes and raise an event as and when jobs get added to the queue or job status gets changed in the queue� I'm using WMI to get Print-Job statuses using WMI with C# code. now, I'm getting all the different statuses from the printer beside printed which is very important for me to know when the job was finished printing the job. now, I managed to get printed status but only if the Keep printed Documents (see attachment) property is on. but all the

You can try this Code also

// Check for possible trouble states of a print job using the flags of the JobStatus property

internal static void SpotTroubleUsingJobAttributes(PrintSystemJobInfo theJob)
{

if ((theJob.JobStatus & PrintJobStatus.Blocked) == PrintJobStatus.Blocked)
{
    Console.WriteLine("The job is blocked.");
}
if (((theJob.JobStatus & PrintJobStatus.Completed) == PrintJobStatus.Completed)
    || 
    ((theJob.JobStatus & PrintJobStatus.Printed) == PrintJobStatus.Printed))
{
    Console.WriteLine("The job has finished. Have user recheck all output bins and be sure the correct printer is being checked.");
}
if (((theJob.JobStatus & PrintJobStatus.Deleted) == PrintJobStatus.Deleted)
    || 
    ((theJob.JobStatus & PrintJobStatus.Deleting) == PrintJobStatus.Deleting))
{
    Console.WriteLine("The user or someone with administration rights to the queue has deleted the job. It must be resubmitted.");
}
if ((theJob.JobStatus & PrintJobStatus.Error) == PrintJobStatus.Error)
{
    Console.WriteLine("The job has errored.");
}
if ((theJob.JobStatus & PrintJobStatus.Offline) == PrintJobStatus.Offline)
{
    Console.WriteLine("The printer is offline. Have user put it online with printer front panel.");
}
if ((theJob.JobStatus & PrintJobStatus.PaperOut) == PrintJobStatus.PaperOut)
{
    Console.WriteLine("The printer is out of paper of the size required by the job. Have user add paper.");
}

if (((theJob.JobStatus & PrintJobStatus.Paused) == PrintJobStatus.Paused)
    || 
    ((theJob.HostingPrintQueue.QueueStatus & PrintQueueStatus.Paused) == PrintQueueStatus.Paused))
{
    HandlePausedJob(theJob);
    //HandlePausedJob is defined in the complete example.
}

if ((theJob.JobStatus & PrintJobStatus.Printing) == PrintJobStatus.Printing)
{
    Console.WriteLine("The job is printing now.");
}
if ((theJob.JobStatus & PrintJobStatus.Spooling) == PrintJobStatus.Spooling)
{
    Console.WriteLine("The job is spooling now.");
}
if ((theJob.JobStatus & PrintJobStatus.UserIntervention) == PrintJobStatus.UserIntervention)
{
    Console.WriteLine("The printer needs human intervention.");
}}
     //end SpotTroubleUsingJobAttributes

get printer status before sending a job with c#, I'm trying to get information about all the print jobs on a certain printer on a certain server. The attached code will return the jobs for all printers on a server,� Hi, I have an application to print multiple labels continuously. After i print the each labels i need to update some information. I need to check the printer job status, if the printing is completed then only i need to update the particular label information.

Monitor jobs in a printer queue (.NET), To view the print queue, select "See what's printing." To check general printer status, select "Properties," and to figure out if something is wrong with the printer � If you didn't get any exceptions from your code then you can safely assume that the printer spooler got the job and is responsible to get it to the printer. Checking the print queue is not reliable. There are good odds that you'll never see the job because it was dispatched quickly.

Print Jobs status using WMI C#, If you have to delete a print job from the queue, go straight to Method D. If you are using your own printer, you most likely have Computer Administrator status. So, I created a class (PrintQueueMonitor) that would allow the user to monitor the print queue for job changes and raise an event as and when jobs get added to the queue or job status gets changed in the queue. Using the code. The attached zip file contains two projects: PrintQueueMonitor; PrintSpooler; The PrintQueueMonitor project has two

How to Check the Printer Status in Windows, (mixed printer brands: Xerox / Ricoh / Sharp 2. retrieving status from each of printers : Brand See more: vb net get printer status, no printer status available, see what's printing, win32 11 freelancers are bidding on average $267 for this job. Inserts a new (generically named) print job, whose content is a Byte array, into the queue. AddJob(String) Inserts a new print job, whose content is a Byte array, into the queue. AddJob(String, PrintTicket) Inserts a new print job for an XML Paper Specification (XPS) Document into the queue, and gives it the specified name and settings.

Comments
  • System.Printing didn't make the cut for .NET 2.0 and probably shouldn't have made the cut for .NET 3.0. It isn't really to blame, the underlying Windows API just isn't strong. Detune your requirements.