如何在raspberry pi中使用php或python打印.xlxs文件?

2024-09-27 07:20:09 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一台打印机连接到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)

那么打印文件应该遵循哪种方法呢


Tags: 文件topathnamelibreofficepiconnprinter

热门问题