Search code examples
printingpostscript

What does a printer driver do? How to intercept/get the data/command it sends to the printer?


What does a printer driver do? For example, when I open a word document, and use File->Print to print the document: what does the printer driver do? Will it convert the .doc document to PostScript, append some printer commands, and then send to the printer?

Another question is how to intercept the data/command the printer driver send to the printer with software, under windows or *nix.


Solution

  • Simply put, a Windows printer driver is a library which implements a Windows-defined interface of device-independent imaging commands, and another interface of communication to devices like printers. Upon receiving calls from the imaging commands interface, it generates a device-specific print file, and sends it to the communications interface.

    In the case of the PostScript printer driver, the driver consists of a shared device-independent part which does most of the conversion of imaging commands to PostScript language code, and a device-dependent part which has the data about the paper sizes and capabilities of a particular printer model. This division, and the fact that the shared part is shared, isn't particularly visible to the user.

    These printing related interfaces are not simple. Two places to start learning about them are Introduction to Printing, by the Microsoft Dev Center, and the article Windows Driver Model, at Wikipedia

    It is possible to intercept the data and send it elsewhere, either at the imaging commands interface or the communications interface. However, it's not a simple task. It requires learning the printing system and its APIs, as in the references above.