How to intercept and change the windows 7 print spool file (.SPL) to add some additional information in the header like '@PJL SET NAME="PainPoint" ' before this file is sent to the printer during the execution of the print job?

The .SPL file partial extract from top is :

%-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

There are 1 answers

9
Nick Westgate On BEST ANSWER

Editing the spool file is obviously trivial. The trick is how to get access to the spool file.

I can think of a few ways offhand:

  1. Pause the print job after spooling, edit it, then release it. See my answer here. This is not trivial and you may need to resort to third-party software depending on time/effort available.
  2. Create a print driver or 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. If you don't need to do this transparently you could set up RedMon (free) to call your app to edit the spool file. RedMon will then send it to the desired printer.

  4. VeryPDF has some similar commercial products with more capabilities.