Slow priniting when I use Python CUPS

1.3k Views Asked by At

When i try to print document with CUPS and xhtml2pdflibrary - everything is good, but i get very slow printing. Is there any solution for this problem?

Here is Python code:

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()
1

There are 1 best solutions below

0
On BEST ANSWER

Trouble was in drivers. Tried to run it on Windows and everything was good.