Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt WebKit
  4. Has anyone tried using pdf.js with QWebKit?
QtWS25 Last Chance

Has anyone tried using pdf.js with QWebKit?

Scheduled Pinned Locked Moved Qt WebKit
6 Posts 3 Posters 5.3k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    thebeast44
    wrote on 21 Apr 2014, 09:07 last edited by
    #1

    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

    1 Reply Last reply
    0
    • S Offline
      S Offline
      stevenceuppens
      wrote on 21 Apr 2014, 13:37 last edited by
      #2

      do you have a small working code example to debug?

      Steven CEUPPENS
      Developer / Architect
      Mobile: +32 479 65 93 10

      1 Reply Last reply
      0
      • T Offline
        T Offline
        thebeast44
        wrote on 21 Apr 2014, 14:56 last edited by
        #3

        [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

        1 Reply Last reply
        0
        • T Offline
          T Offline
          thebeast44
          wrote on 24 Apr 2014, 02:40 last edited by
          #4

          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.

          1 Reply Last reply
          0
          • F Offline
            F Offline
            fstafforini
            wrote on 5 Jun 2014, 00:20 last edited by
            #5

            [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!

            1 Reply Last reply
            0
            • T Offline
              T Offline
              thebeast44
              wrote on 5 Jun 2014, 01:18 last edited by
              #6

              [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 :)

              1 Reply Last reply
              0

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved