我有一台打印机连接到raspberry pi,我想用python或php打印raspberry pi中的.xlxs文件。我尝试过CUPS和libreoffice。通过使用CUPS,我可以打印txt文件,但不能打印任何其他使用python的文件,使用下面的代码
import cups
conn = cups.Connection()
printers = conn.getPrinters()
printer_name = printers.keys()[0]
conn.printFile(printer_name,'path to file',"",{})
通过使用libreoffice和subprocess,我可以打印.xlxs文件,但只能在直接运行python文件时打印,而不能在php文件执行python文件时打印
subprocess.call('libreoffice --pt <printername> <path to file>',shell=True)
那么打印文件应该遵循哪种方法呢
目前没有回答
相关问题 更多 >
编程相关推荐