Click here to Skip to main content
15,881,881 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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.
Posted
Updated 10-Mar-16 4:48am

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.
 
Share this answer
 
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][^]
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900