gpt4 book ai didi

python - 使用 Python CUPS 时打印速度慢

转载 作者:太空宇宙 更新时间:2023-11-04 03:38:35 26 4
gpt4 key购买 nike

当我尝试使用 CUPSxhtml2pdf 库打印文档时 - 一切都很好,但打印速度非常慢。这个问题有解决办法吗?

这是 Python 代码:

import cups
from xhtml2pdf import pisa

def main():
filename = "/home/stopfan/print.pdf"

xhtml = "<h1>Test print</h1>\n"
xhtml += "<h2>This is printed from within a Python application</h2>\n"
xhtml += "<p style=\"color:red;\">Coloured red using css</p>\n"
xhtml += "<h1>Test print</h1>\n"
xhtml += "<h2>This is printed from within a Python application</h2>\n"
xhtml += "<p style=\"color:red;\">Coloured red using css</p>\n"
pdf = pisa.CreatePDF(xhtml, file(filename, "w"))
if not pdf.err:

pdf.dest.close()

conn = cups.Connection()
printers = conn.getPrinters()
for printer in printers:
print printer, printers[printer]["device-uri"]
printer_name = printers.keys()[0]
conn.printFile(printer_name, filename, "Python_Status_print", {})
else:
print "Unable to create pdf file"
if __name__=="__main__":
main()

最佳答案

问题出在司机身上。尝试在 Windows 上运行它,一切都很好。

关于python - 使用 Python CUPS 时打印速度慢,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27684983/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com