Archie3d / qpdf

PDF viewer widget for Qt
GNU Lesser General Public License v2.1
170 stars 58 forks source link

Error loading/displaying some PDF. #7

Closed obiwankennedy closed 6 years ago

obiwankennedy commented 6 years ago

I tried to load a pdf file and I'm running into this error:

js: Uncaught (in promise) TypeError: Cannot read property 'classList' of null
[1:2:0126/013732.141117:ERROR:channel.cc(507)] Invalid message size: 378616088

Your pdfviewer stays completely grey. It is displayed normally into Firefox 58.0.

Archie3d commented 6 years ago

Hi, Do you mind share the pdf file that demonstrates the issue?

obiwankennedy commented 6 years ago

Sure, I sent you an email. Right now.

obiwankennedy commented 6 years ago

Did you get the link ?

Archie3d commented 6 years ago

Yes, I have the file, and can confirm that it does not load correctly. This will probably require upgrading to the latest pdf.js, but since the API has been changes this may take me a while. I'll keep you updated here.

Archie3d commented 6 years ago

The problem is that the pdf file mentioned here was too large (150Mb) and crashed the QtWebView process when passed as base64 string into JavaScript. Currently it is the only way to pass the file content into the browser process without violating the cross origin security measure. I had to disable the web security in the viewer to allow files to be loaded by the browser itself (omitting base64 serialization). The pdf loads correctly now.

obiwankennedy commented 6 years ago

Thanks, I updated the project, but I can't make it to work. Have you commit all your changes ? I'm getting this error:

js: The provided value 'moz-chunked-arraybuffer' is not a valid enum value of type XMLHttpRequestResponseType. [1:2:0203/233858.098543:ERROR:channel.cc(507)] Invalid message size: 378616104

and the latest git commit is : commit ef4312968e6bbe31e419e78047fd93e366b3df0d

If I load the file from the GUI, it uses loadFile instead of loadData.

Archie3d commented 6 years ago

Hi, Yes, this is correct. The 'moz-' errors can be ignored, these are because pdf.js expects Mozilla browser, I guess. I've tested it with Qt-5.9.1 MSVC-2017 and it works fine.

Do you use pdfviewer provided or only qpdflib?

On Sat, Feb 3, 2018 at 10:44 PM, Renaud G. notifications@github.com wrote:

Thanks, I updated the project, but I can't make it to work. Have you commit all your changes ? I'm getting this error:

js: The provided value 'moz-chunked-arraybuffer' is not a valid enum value of type XMLHttpRequestResponseType. [1:2:0203/233858.098543:ERROR:channel.cc(507)] Invalid message size: 378616104

and the latest git commit is : commit ef43129 https://github.com/Archie3d/qpdf/commit/ef4312968e6bbe31e419e78047fd93e366b3df0d

If I load the file from the GUI, it uses loadFile instead of loadData.

— You are receiving this because you were assigned. Reply to this email directly, view it on GitHub https://github.com/Archie3d/qpdf/issues/7#issuecomment-362861583, or mute the thread https://github.com/notifications/unsubscribe-auth/AFgeaUYuTD8sGLCrEkqYgmXLv5mG1zEjks5tROFXgaJpZM4RttIE .

obiwankennedy commented 6 years ago

Both, I integrated your code into one of my project (GPLv2) and I can load small pdf. But It is still not working for big ones. So I updated your code to see if it works on my computer. But it is not.

I'm running on Ubuntu 16.04, with Qt 5.9.3, 64bits.

Archie3d commented 6 years ago

Hi,

Do you make sure you pass "--disable-web-security" command line argument to your QApplication (see main.cpp of pdfviewer)? Can you load your PDF using pdfviewer? I'll try it in Ubuntu.

On Sun, Feb 4, 2018 at 12:01 AM, Renaud G. notifications@github.com wrote:

Both, I integrated your code into one of my project (GPLv2) and I can load small pdf. But It is still not working for big ones. So I updated your code to see if it works on my computer. But it is not.

I'm running on Ubuntu 16.04, with Qt 5.9.3, 64bits.

— You are receiving this because you were assigned. Reply to this email directly, view it on GitHub https://github.com/Archie3d/qpdf/issues/7#issuecomment-362867512, or mute the thread https://github.com/notifications/unsubscribe-auth/AFgeab4Af-KH5CpK5cqZpoopXzkcfynlks5tRPNxgaJpZM4RttIE .

Archie3d commented 6 years ago

Hi, I've committed a small change to explicitly specify file:// This fixes loading on Linux. Tested with Ubuntu and Qt 5.8.0.

obiwankennedy commented 6 years ago

It works fine! Thank you!

To tell you a bit about my plans, I'm the lead developer of a project called: Rolisteam. It is a virtual table to play roleplaying games. And thank to your lib, I added the possibility to load and show pdf files. As role playing games are often available in pdf. this feature is important.

I close the issue. I will test a bit on mac and windows as well in few weeks. Thank you.

Archie3d commented 6 years ago

Great. Glad you found this useful. And good luck with your project, sounds like a lot of fun!

On Sun, Feb 4, 2018 at 4:59 PM, Renaud G. notifications@github.com wrote:

It works fine! Thank you!

To tell you a bit about my plans, I'm the lead developer of a project called: Rolisteam. It is a virtual table to play roleplaying games. And thank to your lib, I added the possibility to load and show pdf files. As role playing games are often available in pdf. this feature is important.

I close the issue. I will test a bit on mac and windows as well in few weeks. Thank you.

— You are receiving this because you were assigned. Reply to this email directly, view it on GitHub https://github.com/Archie3d/qpdf/issues/7#issuecomment-362921856, or mute the thread https://github.com/notifications/unsubscribe-auth/AFgeaexYwTW4Xcsv00jJ_I8jF3Cxt8doks5tReH3gaJpZM4RttIE .