如何以编程方式实现正常windows 打印queue 'spool file' 的假脱机文件header 在发送到打印机之前的编辑?

How to programmatically achieve editing of the spool file header of the normal windows print queue 'spool file' before it is sent to the printer?

如何拦截和更改 windows 7 打印假脱机文件 (.SPL) 以在 header 中添加一些附加信息,例如“@PJL SET NAME="PainPoint"”之前此文件在执行打印作业期间发送到打印机?

顶部的 .SPL 文件部分摘录是:

%-12345X@PJL SET STRINGCODESET=UTF8
@PJL COMMENT DATE=02/08/2017
@PJL ENTER LANGUAGE=PCLXL
) HP-PCL XL;2;1;FXXPL2-1.0.0,WINNT-6.1,XPL2DRV-6.9.1.1
?X???........

编辑假脱机文件显然是微不足道的。诀窍在于如何访问假脱机文件。

随手想到几个办法:

  1. 后台打印后暂停打印作业,编辑它,然后释放它。 See my answer here。这不是微不足道的,您可能需要求助于 third-party 软件,具体取决于可用的 time/effort。
  2. 创建打印驱动程序或spooler component such as a port or language monitor to edit the file. (Thanks to Carey Gregory for the suggestion to use a language monitor). This is a big topic and you'll have to read a lot of documentation to figure out how to do it, but there is a sample (Pjlmon) in the WDK. Note that the newer V4 driver model for Windows 8/Server 2012 doesn't support these components
  3. 如果您不需要透明地执行此操作,您可以设置 RedMon(免费)来调用您的应用程序来编辑假脱机文件。然后 RedMon 会将其发送到所需的打印机。

  4. VeryPDF 有一些 similar commercial products 更多功能。