Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Counting the number of printed pages in C#

I am developing a print spool monitor to count the number of pages that are printed by a certain printer.

I am new to this area, so I am using the following article as my reference.

Print Monitor

Now I have a requirement of counting the double sided pages (duplex) and single sided pages separately. How can I detect this?

like image 927
Chathuranga Chandrasekara Avatar asked Nov 13 '22 15:11

Chathuranga Chandrasekara


1 Answers

This is difficult at best. To do it properly you'd need to run the output (PCL/PS/XPS) through a RIP (Raster Image Processor) that can convert the language to something the printer is actually going to output and see what comes out. You can look at the file for duplex codes in the language that is being used for print, but you could run into problems as duplex might be turned on and off throughout. Also, different manufactures might put this in custom PJL at the start of the job and not in standard PCL or PS coding in the datastream itself.

If accuracy isn't a huge issue then you could parse the data and come up with some numbers but you'll never be exact, especially if the file doesn't explicitly have duplex on or off and the printer is set to on. In this case it will duplex and you'll never know. To add to that, the user might print multi-up (4 pages on a single sheet). If they do this through the application it will report 1 page. If they do it in the printer driver, it may pass 4 pages and let the printer do the layup, in this case you will report 4 pages and not 1. Another case is the user who want 100 copies of a 1 page document. The spooler might only report 1 page because the printer is going to do the work of creating multiple copies.

There are many tools on the market for capturing this data. The accurate ones typically get data from the device after the job is printed. Most modern printers have an ability to track pages printed and users etc.

Sorry I don't have nicer/happier answer for you. Good luck.

like image 160
Douglas Anderson Avatar answered Nov 24 '22 00:11

Douglas Anderson