How to capture EMF file for a print job

How to capture EMF file for a print job

Post by VmVybiB » Fri, 11 Jul 2008 01:04:01

I have been asked to intercept all printing for a POS kind of system, where
every product goes through a printer. I have managed to use EnumPrinters just
fine to get the list of printers. And I've been looking at the various
...PrinterNotification APIs to make a monitor application that will feed the
POS "cash register".

This company takes digital images - so they wondered whether I can make a
thumbnail of the printer output. And this output is likely to be an EMF,

Is there a way to get to the stream or file that is that EMF? I assume that
if I have it, I can run it into another DC.


How to capture EMF file for a print job

Post by Carey Greg » Fri, 11 Jul 2008 04:37:22

Yes, it can be done, and has been done many times. We did it back in 1998
and still have a successful product based on that approach. However, MS
will tell you loud and clear that the spool file format is undocumented
and using it directly is unsupported. And they're right. It's EMF...
sort of. There are a number of significant differences between what
you'll find in a spool file and true EMF.

Also, with each major release of Windows since NT4, MS has modified the
format slightly and made it increasingly difficult to access the spool
file directly. I fully expect them to make it impossible any day now.
It's also likely they'll quit using EMF as a spool file format in the near
future, so don't expect your solution to last long.

With that said, if you still want to use this approach, search the device
driver forums (microsoft.public.development.device.drivers,
microsoft.public.win32.kernel, etc) and you'll find a *lot* of discussion
about this dating back many years. I believe there's also an example
program posted somewhere, though I don't recall where offhand.