Has anyone tried using pdf.js with QWebKit?



  • Hi all,

    I'm trying to use pdf.js to display pdf files in my application.

    I've created custom NetworkAccessManager to supply local pdf file to the script and
    almost everything seemed fine until I came across certain pdf files that took too long to render.

    most pages take less than 5 seconds to finish
    but some pages take more than 60 mins (yes, minutes) to finish,
    making my application completely unusable for those files.

    The same pages take long to load in standard web browser apps such as Chrome, Firefox or Safari too,
    but not as long as it does in QWebKit.

    I've already posted a few questions on their board regarding the issue,
    but they don't seem too keen on helping out with custom implementations
    so I was wondering if anybody tried pdf.js



  • do you have a small working code example to debug?



  • [quote author="stevenceuppens" date="1398087456"]do you have a small working code example to debug?[/quote]

    not at the moment.

    it's going to take some time to make one, which is why I wanted to see if there's anybody else who's already been there.

    I'll get back to you with a minimal implemention some time this week



  • stevenceuppens

    Here's a basic implementation of pdfviewer.

    "pdftest.zip":https://www.dropbox.com/s/hd2hdeeipu6ju9y/pdftest.zip

    you can add your own pdf file to the resource file and change the file name in pdf-viewer.js

    pdf.worker.js has been modified to add little bit of performance output.

    "pdf.js github":https://github.com/mozilla/pdf.js
    or
    "online demo":http://mozilla.github.io/pdf.js/web/viewer.html

    Implementation in Qt WebKit is much slower than standard web browsers such as Firefox, Chrome, Safari or Opera.

    Tests with some problematic pdf files showed that certain pages take 30 second to load in Chrome whereas it took anywhere between 40 to 80 minutes in my Qt Webkit implementation.

    Yes I know it just doesn't make sense to have that much difference but that's what's actually happening on my side which is why this part of my project is about to be put on hold (or abandoned completely)

    if you can't find any pdf file that you can work with, I can also send you the pdf file I mentioned.



  • [quote author="thebeast44" date="1398307247"]stevenceuppens
    Here's a basic implementation of pdfviewer.
    [/quote]

    Thank you for sharing that code! I've been looking for a multi platform solution for displaying PDFs in pyqt, this seems promising!

    [quote author="thebeast44" date="1398307247"]stevenceuppens
    Tests with some problematic pdf files showed that certain pages take 30 second to load in Chrome whereas it took anywhere between 40 to 80 minutes in my Qt Webkit implementation.
    [/quote]

    Do you have an idea of what makes a pdf problematic? I'm interested in displaying mostly scanned images contained within pdfs and maybe some simple invoices, lines and text, maximum 5 pages (it's a very simple digital asset management frontend within a simple accounting software); do you think I'll stumble upon your problems?

    Thanks!



  • [quote author="fstafforini" date="1401927602"]
    Do you have an idea of what makes a pdf problematic? I'm interested in displaying mostly scanned images contained within pdfs and maybe some simple invoices, lines and text, maximum 5 pages (it's a very simple digital asset management frontend within a simple accounting software); do you think I'll stumble upon your problems?

    Thanks![/quote]

    There seems to be two different problems.

    1. The way pdf.js was implemented before it was fixed
      pdf.js used to load operation list - whatever that is - all in one go, which seemed to slow down the entire process when the operation list becomes too large.

    This problem was fixed when they decided to load operation list in short manageable bursts.

    1. The performance of javascript engine in Qt 5.2.0
      It's.. just not as fast as standard web browsers out there. I don't think I can do anything about that at the moment.

    I'm not really sure what causes 'operation list'to be large, since I'm no expert on PDF format, but you can always create some sample documents and see how it goes :)


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.