简体   繁体   English

计算C#中打印页数

[英]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? 我怎么能发现这个?

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. 要正确地执行此操作,您需要通过RIP(光栅图像处理器)运行输出(PCL / PS / XPS),它可以将语言转换为打印机实际输出的内容并查看输出内容。 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. 此外,不同的制造商可能会在作业开始时将其置于自定义PJL中,而不是在数据流本身的标准PCL或PS编码中。

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). 除此之外,用户可以打印多页(单张纸上4页)。 If they do this through the application it will report 1 page. 如果他们通过应用程序执行此操作,它将报告1页。 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. 如果他们在打印机驱动程序中执行此操作,它可能会传递4页并让打印机执行上下文,在这种情况下,您将报告4页而不是1页。另一种情况是需要100页1页文档的用户。 The spooler might only report 1 page because the printer is going to do the work of creating multiple copies. 假脱机程序可能只报告1页,因为打印机将完成创建多个副本的工作。

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. 祝好运。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM