virtualPrinter
This library allows you to easily create a windows virtual printer.
How to use
- Simply create a
Printer('my printer name',acceptsFormat='png')
object, and implement its printThis(doc,title=None,author=None,filename=None)
method.
- It should show up in your list of windows printers.
- Every print job ultimately calls your
printThis()
with a new doc in the acceptsFormat
format
- see the examples directory for details
Theory of Operation
- Open a TCP server on a (loopback) adapter
- Tell Windows to install a PostScript network printer that lives at that address:port
- Whenever a print job comes in on that network port, call commandline GhostScript (required) to convert the PostScript into a PDF (works great, since the two formats are closely related)
- Use PIL to read that PDF into an image
- User code gets passed a normal, everyday, PIL image, plus some meta info (title,user,etc) gleaned from the original PostScript