Click here to Skip to main content
15,888,816 members
Please Sign up or sign in to vote.
4.33/5 (2 votes)
Hello,

I'm using System.Printing to get the information about the jobs in spoolers.

I can ger the basic information about job name, number of pages, etc. but I have the problem with getting the information about job color, duplex usage or number of copies.

I use HostingPrintQueue.CurrentJobSettings.CurrentPrintTicket but thes values are still the default and not the selected values during the print dialog.

Here is my code:

string jobName;
       string jobSubmitter;
       string jobPrinter;
       int jobNumOfPages;
       string jobDuplex;
       string jobColor;
       int jobCopies;

       PrintServer ps = new PrintServer();
       foreach (PrintQueue pq in ps.GetPrintQueues())
       {
           PrintQueue _spooler;

           _spooler = new PrintQueue(new PrintServer(), pq.Name);

           PrintJobInfoCollection jobs = _spooler.GetPrintJobInfoCollection();
           foreach (PrintSystemJobInfo job in jobs)
           {
               if (job.IsPrinted)
               {
                   jobName = job.Name;
                   jobSubmitter = job.Submitter;
                   jobPrinter = job.HostingPrintQueue.FullName;
                   jobNumOfPages = job.NumberOfPagesPrinted;
                   jobDuplex = job.HostingPrintQueue.CurrentJobSettings.CurrentPrintTicket.Duplexing.Value.ToString();
                   jobColor = job.HostingPrintQueue.CurrentJobSettings.CurrentPrintTicket.OutputColor.Value.ToString();
                   jobCopies = job.HostingPrintQueue.CurrentJobSettings.CurrentPrintTicket.CopyCount.Value;

                   lbLogs.Items.Add("Name:" + jobName + " Submiter:" + jobSubmitter + " Printer:" + jobPrinter + " Pages:" + jobNumOfPages + " Color:" + jobColor + " Duplex:" +jobDuplex + " Copies:" + jobCopies);
                   job.Cancel();
               }

           }
       }


Please can somebody help?

Regards, Broso
Posted
Comments
Kschuler 17-Jul-14 9:27am    
From what I understand, which isn't much, it's very difficult because each printer has different capabilities and there isn't a standard (that I know of) for how those settings are stored. You might have to look into something hardware specific.
bsopik 21-Jul-14 5:59am    
Yes I know. But this shall be a stadard feature of system.printing.

1 solution

I think you have to fall back on the Windows API.
Try the control on PrintQueueWatch.codeplex.com and see if that works for you?
 
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