Quantcast
Channel: Qt DevNet forums: Qt WebKit
Viewing all articles
Browse latest Browse all 542

Problem converting html to pdf on Windows

$
0
0
This blogger says the code below works on linux but not Windows though I have not tried it on Linux myself: https://bharatikunal.wordpress.com/2010/01/ I realize this may be a windows problem but that is what I am working with. Other than serving my html via http, can anyone think of a work around? Note: If I use web.load() instead of web.setHtml() it works fine. web.show() properly displays the page in either case. import sys from PyQt4.QtCore import * from PyQt4.QtGui import * from PyQt4.QtWebKit import *   app = QApplication(sys.argv)   web = QWebView()   html = open('//myhtml//notes.html').read() web.setHtml(html) #web.load(QUrl("http://www.google.com"))   #web.show()   printer = QPrinter() printer.setPageSize(QPrinter.A4) printer.setOutputFormat(QPrinter.PdfFormat) printer.setOutputFileName("file.pdf")   def convertIt():     web.print_(printer)     QApplication.exit()   QObject.connect(web, SIGNAL("loadFinished(bool)"), convertIt)   sys.exit(app.exec_())

Viewing all articles
Browse latest Browse all 542

Trending Articles