Passing data from a virtual printer to python
I am trying to make a thing where in other applications you can print to a certain printer and python will get the data. How would I go about making this? 开发者_JAVA技巧It would have to work in all applications, so it would appear as a normal printer, and work on Linux and Windows, even if I have to rewrite it for both.
So to recap: One opens a program and hits the print button. It brings up the printer dialogue and they select the python printer, like any other printer. After they accept, the python program which loaded the module (this will probably be a module) gets the data that the other application printed.
Most Linux distros (and OS X) and use CUPS to do printing these days. A CUPS backends for a specific printer is ultimately just an executable, which you can make do anything you want. The CUPS project provides filter/backend API documentation. There also exists at least one open-source CUPS virtual printer in the form of CUPS-PDF, which might make for a useful example to consult.
On the Windows side I'm afraid I can't help you.
精彩评论