[Tutor] Printing from python

Ben Finney ben+python at benfinney.id.au
Fri Mar 14 22:25:17 CET 2014


Ulrich Goebel <ml at fam-goebel.de> writes:

> So I look for a (nice documented) library which give access to the
> CUPS API or something else to print the PDF from python.
>
> Any help is welcome!

The problem isn't really one to be solved within your program, IMO.

Printing is implemented as a service at the operating system (OS) level.
Once you have a document in a form suitable for sending to a printer
(such as a PDF), the OS is where any problems with the actual printing
need to be addressed.

Also, since it is implemented at the OS level, you're not going to find
a solution in a platform-agnostic programming language like Python. The
solution, whatever it is, will be highly dependent on the services
presented by your specific OS.

Of course, once you have a suitable OS service for printing the
document, Python can send the document to that service. But at that
point, the Python code will be trivially easy: probably invoking an
external command via ‘subprocess.call’ or ‘subprocess.check_call’.

In short: printing is a problem to be solved via the OS, not via Python.

-- 
 \     “We are not gonna be great; we are not gonna be amazing; we are |
  `\           gonna be *amazingly* amazing!” —Zaphod Beeblebrox, _The |
_o__)                Hitch-Hiker's Guide To The Galaxy_, Douglas Adams |
Ben Finney



More information about the Tutor mailing list