Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the simplest way (in python) to print to a remote IPP/CUPS server or printer?

I have a postscript file and want it to be printed on a IPP capable device (or CUPS server). What is the minimal code and dependencies I could get away with to do that.

Using LPR or libcups gives me lot of cross-plattform dependencies. So my first approach was to implement a minimal subset of IPP (the protocol used by cups and many modern printers) since "it's only extended HTTP". But unfortuntely a IPP client is a lot more code than a few lines and so far I found no IPP client implementation meant for just printing and not managing a printserver.

I would prefer a solution in Python, but would also be happy with something in an oter dynamic language.

like image 930
max Avatar asked Aug 19 '09 21:08

max


People also ask

How do I print to a cup printer?

The process to access CUPS is the same: Ensure CUPS is installed, open a network, and navigate to localhost:631 . Once you've accessed the CUPS web interface, select the Administration tab. Click the Find New Printers button in the Printers section, and then add the shared printer to your network.

How does IPP printing work?

IPP printing uses the Internet Printing Protocol (IPP) and prints information via the network. IPP that is extended HTTP is used to forward printing data, enabling you to print data on a printer on a distance location via the Internet.

Which service is used for printing and handling the interaction with printer?

The Print Services system consists of a distributed system of print servers that manage printers and make them available to print clients. One or more servers may be used, each server independently managing one or more printers.


2 Answers

you need to add remote printer to CUPS:

lpadmin -p printername -E -v //IPADDRESS/spool -m driver.ppd

where driver.ppd is the driver to print with

ps: this could also work for programatic access, if printer is set before.

like image 163
dusoft Avatar answered Sep 17 '22 13:09

dusoft


pycups is an excellent tool; here is an example of some code that uses it - including setting some options like fit-to-page https://sourceforge.net/p/coils/coils-code/ci/master/tree/coils/logic/workflow/actions/doc/ipp_print.py#l58

There is also code floating around for using the LPR protocol. https://sourceforge.net/p/coils/coils-code/ci/master/tree/coils/logic/workflow/actions/doc/lpr_print.py

Communicating directly with the print server is much better than wrapping a platform dependent command line tool.

like image 33
Adam Tauno Williams Avatar answered Sep 21 '22 13:09

Adam Tauno Williams