2

This Python code works in Windows but does not work in Raspbian. How do I print PDF files using the Raspberry Pi?

    import os
    fd = os.startfile("/home/pi/Desktop/a.pdf", "print")
1

You could use CUPS

import cups
conn = cups.Connection()
printers = conn.getPrinters()
printer_name = printers.keys()[0]
conn.printFile(printer_name,'/home/pi/Desktop/a.pdf',"",{}) 
1

os.startfile()'s "print" option is not available in Raspbian (the OS of the Raspberry Pi). Make sure that your printer is connected to the Pi, and use Popen and lpr to communicate with the printer daemon.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.