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

3

10

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.

Sajovich answered 19/8, 2009 at 21:11 Comment(0)
B
1

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.

Buskin answered 19/8, 2009 at 21:16 Comment(2)
This obviously needs a working local cups installation, a requirement I like to avoid - especially on Windows.Sajovich
also check this (old) tutorial: owlfish.com/thoughts/winipp-cups-2003-07-20.htmlBuskin
X
1

There's a python wrapper for CUPS ipptool available at github:

This python lib looks also promising:

You might also want to check this answer.

Xylophagous answered 28/1, 2015 at 21:57 Comment(0)
U
1

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.

Unproductive answered 31/5, 2018 at 12:36 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.