If you want an easy, generic, device-context free way to mess with printing, go to the only place where it is anything close to easy, generic and context free- the Win32 API the app issues. Hook them and implement your monitoring and control scheme there. While I know how to hook UM code, I have little practical experience or need (might change now that I’m testing UMDF, though), so I suggest you get any how-to’s elsewhere. I hear Detours is nice…
Re: using a plugin: As Tim pointed out, even the plug-in can’t tell you what text is being printed in every case (although as I remember it, Acrobat created funky fonts with oddball names on the fly, and all of the character codes were in the “vendor-specific” [nomenclature is probably inexact, I haven’t been near printing in years, which makes me very happy] reserved range for Unicode). At any rate [back to working via a UM hook and what Tim mentioned], Glyph indexing is supported in ExtTextOut, so you’re going to have to some gnarly deciphering of fonts if you want to roll back from indices to character codes in the event you intend to cover everything, even by hooking the app.
As for a port monitor: A port monitor is generally going to see the PDL for the printer, which in terms of finding characters means all you have to do for an ironclad solution is:
[1] know every PDL on the planet [since you don’t know what the printer is using, you’re just a pipe to get data in and out of it], so you can first properly identify and then properly interpret it.
[2] have perfect character recognition from graphics, because the driver could have chosen to send text as graphics. For even more fun, if the characters are large and banding is involved, you may have to have an algorithm that can piece together the bands and recognize characters…
[3] Be able to put all of the above together to be able to suppress the output or shut off all further output and not leave the device in an unusable state. Of course, if the idea is to never let the output even appear, then there’s the issue of squirreling away GB or more of data while you decide if you want to let the thing get printed or not.
Port monitor? Probably not the way to go [but it would be my idea of “fun”].
OT- Cancellation issues trigger this- I recall I once had a driver that when the output stream failed a write because the job had been cancelled, began saving the sent data off to the side (until the resulting cancellation state detection was recognized by the earlier parts of the engine), then with the aid of the UI spooled a high-priority “cancel completion job” that sent that data [thus completing whatever output command was in process when the spooler processed the “Cancel” request, correctly], along with proper page/job end (including page eject) codes. State of the art for the competition at the time was “emit a whole bunch of NULLs and a formfeed” in a similar type of follow-on job. Only remember it because it was one of the rare times I clearly hands down beat them- my method was much faster completing a canceled job- several seconds in some cases. Oops, forgot to patent it, and now anyone [who understood this rambling sketch] can do it. Mortified, I truly be…
Yeah, I actually once wrote a GDI spooling “universal” driver in a market that already had more of them than it needed- didn’t exactly make much impact, though, and Win2K and XP introduced changes that would have broken it completely if it had…
More on-topic: I suppose there’s also a potential spec issue: For instance. if the purpose is to prevent naughty words, what do I do if the swear is printed to a symbol font? Perhaps “F***” in Zapf Dingbats is a perfectly reasonable usage…
Big Brother- coming soon to a printer near you? Given all the fine things spammers have done to evade filters, I suspect any text suppression technology is going to require endless maintenance, no matter how well technically implemented- it’s rather difficult to stop determined communication [not that the difficulty’s ever stopped those so inclined from trying].
Wow, technical trivia, autobiographical trivia, and trivial philosophy, all in one post- that’s GOOOOOOD Starbucks [and a nice mid-week holiday, to boot]!!!