Click here to Skip to main content
15,888,351 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
am searching for a namespace in C# through which i can "print and monitor printing".Currently i used 'process' to print a pdf ; But here i cannot monitor printing.Since process just throws document to printer.I went through Win32_Printer and System.printing both of them are dealing with "controlling/monitoring print jobs" but not printing a document.

How i print now:

C#
ProcessStartInfo psInfo = new ProcessStartInfo();
psInfo.Arguments = ConfigurationManager.AppSettings["printer_name"];
psInfo.FileName = fileName;
psInfo.WindowStyle = ProcessWindowStyle.Hidden;
psInfo.Verb = "print";
psInfo.CreateNoWindow = false;
psInfo.UseShellExecute = true;
process = Process.Start(psInfo);



what WMI does: A simple approach for controlling print jobs using WMI and http://msdn.microsoft.com/en-us/library/aa394370.aspx

All i need to do is check print status of a document i have printed at the moment.Printed or not!!
Posted

1 solution

SQL
To get a list of print queues on the local machine, try PrintServer's GetPrintQueues method.

Once you have an instance of the PrintQueue object associated with the relevant printer, you can use it to access the printer's status (IsOffline, IsPaperOut, etc.). Also, you can use it to get a list of the jobs in the given queue (GetPrintJobInfoCollection) which then will allow you to get job-specific status information (IsInError, IsCompleted, IsBlocked, etc.).


http://support.microsoft.com/kb/322091[^]
C#
foreach (ManagementObject printJob in printJobs)
    {
        // The format of the Win32_PrintJob.Name property is "PrinterName,JobNumber"
        string name = (string) product["Name"];
        string[] nameParts = name.Split(',');
        string printerName = nameParts[0];
        string jobNumber = nameParts[1];
        string document = (string) product["Document"];
        string jobStatus = (string) product["JobStatus"];

        // Process job properties...
    }
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900