如何将文本添加到打印队列中的文档 [英] How do i add text to a document that comes to the print queue

查看:392
本文介绍了如何将文本添加到打印队列中的文档的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我正在搜索.net中的解决方案,在每个到达打印队列的文档的末尾添加一些文本(基于打印机名称)。我可以轻松拦截打印作业,但在包含文档内容的PrintJob对象中找不到任何属性。这甚至可以使用.net或shuld我使用其他语言吗?



我尝试过:



我试图使用

 StringCollection printJobCollection = new StringCollection(); 
string searchQuery =SELECT * FROM Win32_PrintJob;

ManagementObjectSearcher searchPrintJobs = new ManagementObjectSearcher(searchQuery);
ManagementObjectCollection prntJobCollection = searchPrintJobs.Get();



但我找不到内容属性。

解决方案

打印作业的内容不一定是文本:它很可能是专用于打印机制作的专有格式(甚至可能是模型) - 所以即使你可以得到它,那里并不保证您的更改不会使打印输出无用且无法读取。还记得打印作业无法正常启动时的情况吗,打印机只是在页面上喷出象形文字吗?



如果你需要在所有页面上打印一些东西文件,然后你可能需要制作一个打印驱动程序,提供真正的打印驱动程序并添加它自己的水印 - 但我从来没有尝试过,我认为这不是一件容易的事。

打印输出的数据可供打印处理器使用,您必须获得SDK并编写自己的打印处理器。



网上有一些工具:



适用于Windows 7的Virtual Printer SDK, Windows 8,C ++,C#,Delphi,VB.NET,VB [ ^ ]



另外值得一读:



Windows Sp ool文件[未记录的打印] [ ^ ]

Hello, I am searching for a solution in .net to add some text to the end of every document that comes to the print queue (based on printer name). I can intercept print jobs easily but could not find any property in the "PrintJob" object containing document contents. Is this even possible using .net or shuld I use another language?

What I have tried:

I have tried to get the print job contents using

StringCollection printJobCollection = new StringCollection();
string searchQuery = "SELECT * FROM Win32_PrintJob";

ManagementObjectSearcher searchPrintJobs = new ManagementObjectSearcher(searchQuery);
ManagementObjectCollection prntJobCollection = searchPrintJobs.Get();


but I cant find a "content" property.

解决方案

The "content" of a print job isn't necessarily text: it's quite likely to be in a proprietary format specific to the printer make (and maybe even model) - so even if you could get at it, there is no guarantee that your changes won't just make the printout useless and unreadable. Remember what it's like if a print job doesn't start properly, and the printer just spews pages with hieroglyphs all over them?

If you need to print something on all documents, then you probably need to make a print driver that feeds the "real" print driver and adds it's own watermark - but I've never tried, and I don't think it would be an easy thing to do.


The data for the printed output is available to the print processor, you would have to get the SDK and write your own print processor.

There are some tools online:

Virtual Printer SDK for Windows 7, Windows 8, C++, C#, Delphi, VB.NET, VB[^]

Also worth reading:

Windows Spool Files [Undocumented Printing][^]


这篇关于如何将文本添加到打印队列中的文档的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆