1

I am creating a custom print job monitoring application in C# Win Forms, I am able to get most the print job information using PrintJobInfoColletion but I am not able to get number of copies here is my code so far:

PrintJobInfoCollection jobs = pq.GetPrintJobInfoCollection();
        foreach (PrintSystemJobInfo job in jobs)
        {

            string[] row = new string[] { job.JobIdentifier.ToString(),
                                          pq.Name,
                                          job.Name,
                                          job.JobStatus.ToString(),
                                          job.Submitter,
                                          job.NumberOfPages.ToString(),
                                          ((job.JobSize / 1024f) / 1024f).ToString("N2") + " MB",
                                          job.TimeJobSubmitted.ToLocalTime().ToString() };
            dataGridView1.Rows.Add(row);                 
        }

While I tried this code to get a number of copies which is always returning me 1

var copies =  job.HostingPrintQueue.CurrentJobSettings.CurrentPrintTicket.CopyCount;

I have been trying over for a week now and still can not find solutions for my problem, my aim is to get a total number of pages printed in a particular job. PrintJob.NumberOfPagesPrinted is also returning zero.

  • Maybe I've missunderstood what you're trying to achieve, but why don't you just use the `.Count()` method, inherited by `IEnumerable`, should return the count of the job infos in your collection. And what do you mean by "copies", perhaps that's what I can't understand, if my answer does not fullfill youre demands. – D. Petrov Jun 27 '16 at 10:56
  • let me explain it better, User prints a file of 2 pages and selects 3 copies of it. I am getting job.NumberOfPages = 2. Here i am unable to get copies count that is 3, my target is to get total number of pages that is 6. – Ali Ahmed Sahi Jun 27 '16 at 11:03
  • When is the choice of how much pages to copy happening? Sincerelly, I have no idea how you could succeed with that, since I've never worked in details with this class. – D. Petrov Jun 27 '16 at 11:06
  • Thanks for your help, choice of how much to copy can be from any windows appliction, when ever user tries to print some thing this application which catch the Print Job. – Ali Ahmed Sahi Jun 27 '16 at 11:09
  • In worst case senerio this can be other way around. Instead of getting number of copies for a print job can we SET number of copies for a print job? – Ali Ahmed Sahi Jun 27 '16 at 11:11
  • I think there is plenty of info on this in the web. Take a look at [this](https://social.msdn.microsoft.com/Forums/en-US/8bbe88d7-c9b8-4bc4-8f28-9eabcafa2dd4/printing-problem-need-help?forum=vblanguage) and [this](https://social.msdn.microsoft.com/Forums/vstudio/en-US/9900d2b4-4eb2-4b13-8ba2-e7be07c8e825/how-to-get-number-of-copies-in-print-queue?forum=vbgeneral). A common search with something like `get number of selected copies PrintSystemJobInfo c#` in google will also satisfy your need, I think. – D. Petrov Jun 27 '16 at 11:16
  • … and [this link](http://www.codeproject.com/Questions/863299/How-to-get-number-of-printed-pages) – stuartd Jun 27 '16 at 11:17
  • I tried googling for over 3-4 days now i have already gone through these post, microsoft post are old and results are generating invalid result. – Ali Ahmed Sahi Jun 27 '16 at 11:22

0 Answers0