windowsapiprintinghookprint-spooler-api

Yes/No Dialog on every page the printer will print


I'm doing this in a printer server. I am trying to make a program that will show up a Yes/No dialog box before proceeding to print a page printed by any application or from the network.

So far, it was easy to pause and resume a job. But haven't found a solution to pause and resume a page to be printed.

For reference, here's more about controlling the printer on Windows https://msdn.microsoft.com/en-us/library/windows/desktop/ff686805(v=vs.85).aspx

I am using Windows 10 64bit. Any language will do.

Thanks.


Solution

  • I'm prepared to be proven wrong, but I don't believe this is trivially possible. The print spooler doesn't have a notion of where pages begin and end in a spooled print session.

    The location of each page is language dependent, and the print spooler can hardly be expected to parse the stream to find the start and end of each page, it would be very slow for one thing.

    The alternative would be for the print processor to note the beginning and end of each page and the offset of the spool file at that moment, and then pass that information separately to the spooler.

    But there are problems with that too. the 'RAW print' capability allows the printing application to inject 'stuff' straight into the print stream, bypassing the print processor altogether. This is common with page layout applications when printing to a PostScript printer for example, particularly on Windows as supporting CMYK isn't really possible when printing on Windows, and spot colours are even harder.

    The injected code can contain any number of pages and the print spooler has no way to know where each page is.

    So in the general case, I don't think this is possible, at least not in the print spooler.