1 Attachment(s)
QWebView print() generates huge PDF files on Windows
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:
Code:
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_())
Re: QWebView print() generates huge PDF files on Windows
Re: QWebView print() generates huge PDF files on Windows
Quote:
Originally Posted by
ChrisW67
I've already looked at QWebSettings attributes but it doesn't help.
If I unset that attribute I don't get any background. Instead I want to get a PDF containing the table elements with their background color.
What I don't like is to get a 10MB file without any logical reason. Every PDF reader I've tried takes too much time to load each page of a such PDF file, and the HTML doc I attached is a simplified version of the one I have.