Results 1 to 3 of 3

Thread: QWebView print() generates huge PDF files on Windows

  1. #1
    Join Date
    Sep 2012
    Posts
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default 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:
    Qt Code:
    1. from PyQt4.QtGui import QApplication, QPrinter
    2. from PyQt4.QtCore import QObject, SIGNAL
    3. from PyQt4.QtWebKit import QWebView
    4.  
    5. webView = None
    6.  
    7. def onLoadFinished( ok ):
    8. global webView
    9. printer = QPrinter( QPrinter.HighResolution )
    10. printer.setOutputFormat( QPrinter.PdfFormat )
    11. printer.setOutputFileName( "out.pdf" )
    12. webView.print_( printer )
    13.  
    14. if __name__ == "__main__":
    15. import sys
    16. app = QApplication(sys.argv)
    17.  
    18. webView = QWebView()
    19. webView.show()
    20. QObject.connect(webView, SIGNAL("loadFinished(bool)"), onLoadFinished)
    21.  
    22. html = ""
    23. with open("html.txt", 'r') as fin:
    24. html = fin.read()
    25. webView.setHtml( html )
    26.  
    27. sys.exit(app.exec_())
    To copy to clipboard, switch view to plain text mode 
    Attached Files Attached Files
    Last edited by brush.tyler; 25th September 2012 at 18:18.

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: QWebView print() generates huge PDF files on Windows


  3. #3
    Join Date
    Sep 2012
    Posts
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QWebView print() generates huge PDF files on Windows

    Quote Originally Posted by ChrisW67 View Post
    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.

Similar Threads

  1. Print a QWebView many times
    By Eddyc in forum Qt Programming
    Replies: 0
    Last Post: 28th August 2012, 11:37
  2. Huge Mac .dmg files, can anything be done to make them smaller?
    By colin207 in forum Installation and Deployment
    Replies: 3
    Last Post: 10th February 2011, 09:06
  3. QWebView print to PDF and add background image
    By supergillis in forum Qt Programming
    Replies: 0
    Last Post: 9th September 2010, 14:02
  4. HUGE BUG in Windows Installation!!!
    By joandelason in forum Installation and Deployment
    Replies: 9
    Last Post: 22nd March 2010, 10:07
  5. Huge error list from qt files
    By Raccoon29 in forum Qt Programming
    Replies: 4
    Last Post: 8th September 2008, 16:22

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.