Hi all,
I tried both on Ubuntu 11.04 and Windows7 to print a html document loaded in QWebView to a PDF file.
On Ubuntu the output PDF file size is about 35KB.
On Windows using PdfFormat as output format the generated PDF file it's 10MB! but using instead PDFCreator as printer the file size is 35KB like on Ubuntu.
The HTML doc contains no images, just some texts and tables.
Looking at the huge PDF files (Win version) I've noticed the background of each page is converted to image (even if it's white/transparent) and I suppose this cause the bigger file size.
I'm using QT4.7.2 on Ubuntu 11.04 vs. QT4.7.1 on Windows7.
Is there a way to get on Windows the same behaviour I've on Ubuntu?
The HTML doc is attached.
Here's the python code I used to reproduce the problem:
from PyQt4.
QtCore import
QObject,
SIGNALfrom PyQt4.QtWebKit import QWebView
webView = None
def onLoadFinished( ok ):
global webView
printer.
setOutputFormat( QPrinter.
PdfFormat ) printer.setOutputFileName( "out.pdf" )
webView.print_( printer )
if __name__ == "__main__":
import sys
webView = QWebView()
webView.show()
QObject.
connect(webView,
SIGNAL("loadFinished(bool)"), onLoadFinished
)
html = ""
with open("html.txt", 'r') as fin:
html = fin.read()
webView.setHtml( html )
sys.exit(app.exec_())
from PyQt4.QtGui import QApplication, QPrinter
from PyQt4.QtCore import QObject, SIGNAL
from PyQt4.QtWebKit import QWebView
webView = None
def onLoadFinished( ok ):
global webView
printer = QPrinter( QPrinter.HighResolution )
printer.setOutputFormat( QPrinter.PdfFormat )
printer.setOutputFileName( "out.pdf" )
webView.print_( printer )
if __name__ == "__main__":
import sys
app = QApplication(sys.argv)
webView = QWebView()
webView.show()
QObject.connect(webView, SIGNAL("loadFinished(bool)"), onLoadFinished)
html = ""
with open("html.txt", 'r') as fin:
html = fin.read()
webView.setHtml( html )
sys.exit(app.exec_())
To copy to clipboard, switch view to plain text mode
Bookmarks