Skip to content
This repository has been archived by the owner on Jun 6, 2024. It is now read-only.

What about the use of Resources files ? #2

Open
obiwankennedy opened this issue Jan 25, 2018 · 6 comments
Open

What about the use of Resources files ? #2

obiwankennedy opened this issue Jan 25, 2018 · 6 comments

Comments

@obiwankennedy
Copy link

obiwankennedy commented Jan 25, 2018

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) ?

@yshurik
Copy link
Collaborator

yshurik commented Jan 25, 2018

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.

@obiwankennedy
Copy link
Author

obiwankennedy commented Jan 30, 2018

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.

@yshurik
Copy link
Collaborator

yshurik commented Jan 30, 2018

I guess so. You can make adjustments to communicator to send bytes of pdf document to js

@yshurik
Copy link
Collaborator

yshurik commented Jan 30, 2018

Another way - you may try to prepend with "file://"

@obiwankennedy
Copy link
Author

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.

@coyoteazul
Copy link

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants