Click here to Skip to main content
15,886,362 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi, I've been working on small project which should monitor print queues using c#. The thing that I'm strugling is how to take number of copies and totalpages before printing using c#? I used ManagementObject properties but it did another job which I don't expect.
Could you help?
Thanks beforehand :)

What I have tried:

I've tried to call TotalPages property through ManagementObject instance but it shows every time zero. Is there any way to overcome this?
Posted

1 solution

Not really, no.

You are reading the properties of the print job as it is added to the spooler.

At this point the spooler / print subsystem does not know how many pages it is going to receive because it is receiving them asynchronously...what you need to do is pause the print side until the whole job is spooled and at that point you can check how many pages are in it.
 
Share this answer
 
Comments
Little@Knight 21-Feb-16 2:27am    
Thank you! :)
Little@Knight 21-Feb-16 2:41am    
Did you mean pausing Spooler when a print request is entering to Spooler directory,
Another thing pausing printer when print request is sent to Spooler?
Duncan Edwards Jones 21-Feb-16 2:49am    
Set the printer status to paused until the whole job is in the spooler - there is also a flag in the advanced settings to prevent printing before the entire file is spooled.
Little@Knight 21-Feb-16 4:31am    
The concise description of my target is that my code worked well in pausing, resuming and cancelling jobs with "HP ePrint" because the printer is Paused automatically I couldn't get how it's done, but anyway it (that printer) didn't even show number of pages actually it must show also number of pages of document, user, time and state of printer at printer folder, however it didn't show number of pages.
Then I created another printer at printer folder/faxes then it showed number of pages but I couldn't pause or cancel job with my code:(
There should be general solution I think...
Little@Knight 23-Feb-16 8:42am    
Hi, your suggestion was very efficient. I could pause the printer using a code and got TotalPages. But there is another issue that using ManagementObject I couldn't take number of "copies". Is there any way to get it???
Thanks in advance :)

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