2014-12-29 10 views
2

CUPSxhtml2pdf 라이브러리를 사용하여 문서를 인쇄하려고하면 모든 것이 좋지만 매우 느리게 인쇄됩니다. 이 문제에 대한 해결책이 있습니까?Python CUPS를 사용할 때 느린 초기화 설명

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() 
+0

천천히 무엇을 의미합니까? pdf 파일을 프린터로 보내거나 프린터와 연결하기에는 너무 많은 시간이 소요됩니까? –

답변

2

문제가 드라이버에 있었다 : 여기

파이썬 코드입니다. Windows에서 실행하려고했는데 모든 것이 좋았습니다.