qpdfjs
qpdfjs copied to clipboard
What about the use of Resources files ?
I'm seeing those lines in your code:
auto url = QUrl::fromLocalFile(app_path+"/minified/web/viewer.html");
QDir dir(app_path+"/minified/web/");
Have you tried to use embedded resources from Qt. Instead of file beside your application it will be inside. Easier to make it movable. Do you think is it possible (or you did not try for some reason) ?
I didn't try. It is a question support of qresource vfs inside of WebKit. If no then WebKit just can open such files. You can just give a try to know this.
Ok, I tried I am able to load pdf from resource files but not from file system.
The causes is about webengineview. When you set qrc:/viewer.html, the web engine keeps the qrc:/ as the root of the protocol. So when i set the pdf path. It adds qrc:/ in front of it. The only solution is to provide a way to set pdf data instead of pdf path.
Is there a way to amend your communicator to allows setting pdf data ? It is mostly javascript. I know that pdf.js can display pdf from data.
I guess so. You can make adjustments to communicator to send bytes of pdf document to js
Another way - you may try to prepend with "file://"
Yeah, I've tried already but it does not support different url scheme at the same time.
I modify the communicator to manage data. But on javascript side I can't find the right thing to do to load the data as data and not string/path.
Hi. The solution for this is adding "qrc:" to HOSTED_VIEWER_ORIGINS in the app.js file before minifying. This makes pdf.js think it's hosted, so it can open files from any location