2
import cups
conn = cups.Connection()
printers = conn.getPrinters()
printer_name = printers.keys()[0]
conn.printFile(printer_name,'/home/pi/Desktop/tempprint.jpg',"Hello",{}) 

how to printFile change to print text example "hello world"? not file. thank you

  • 2
    Generate a file first. – Ignacio Vazquez-Abrams Oct 08 '17 at 07:41
  • Source code @ https://github.com/Distrotech/pycups/blob/140c5591190b7dfc2516eee7ef9cc0769696ce4c/cupsconnection.c clearly expects a file. As said above dump to a temp file and delete it later – chakradhar kasturi Oct 08 '17 at 07:55
  • Do you have a printer installed in the system? Maybe first you should look at [this](https://www.howtogeek.com/169679/how-to-add-a-printer-to-your-raspberry-pi-or-other-linux-computer/) – Sid110307 Dec 14 '20 at 10:20

0 Answers0