【问题标题】:Slow priniting when I use Python CUPS使用 Python CUPS 时打印速度慢
【发布时间】:2014-12-29 07:23:27
【问题描述】:

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

这里是 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()

【问题讨论】:

  • 慢是什么意思?花费太多时间将 pdf 文件发送到打印机或与打印机建立连接?

标签: python printing cups cups4j


【解决方案1】:

问题在于驱动程序。尝试在 Windows 上运行它,一切都很好。

【讨论】:

    猜你喜欢
    • 2016-10-10
    • 1970-01-01
    • 2016-10-14
    • 1970-01-01
    • 2018-03-16
    • 2012-09-09
    • 1970-01-01
    • 1970-01-01
    • 2018-10-03
    相关资源
    最近更新 更多