from PyQt4.QtGui import QTextDocument, QPrinter, QApplication import sys app = QApplication(sys.argv) doc = QTextDocument() location = "c://apython//Jim//html//notes.html"html = open(location).read() doc.setHtml(html) printer = QPrinter() printer.setOutputFileName("foo.pdf") printer.setOutputFormat(QPrinter.PdfFormat) printer.setPageSize(QPrinter.A4); printer.setPageMargins (15,15,15,15,QPrinter.Millimeter); doc.print_(printer) print "done!"
python html to pdf
原文链接:https://www.laialex.com/post/python-html-to-pdf-v4u.html