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")

You could use CUPS

import cups
conn = cups.Connection()
printers = conn.getPrinters()
printer_name = printers.keys()[0]
| improve this answer | |

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.

| improve this answer | |

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.