M-Reimer / android-pdf-js

Firefox Addon for Firefox on Android. Opens PDF files using PDF.js

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Feature Request] Allow opening of local pdf files

Septolum opened this issue · comments

If possible, it'd be really useful to open local pdfs using this add-on.
Firefox itself can access the file using the file:/// protocol, once storage permission has been given, but trying to manually input the file URL into the extension via the address bar doesn't seem to work

Do you get any error messages in browser console?
My guess is that an addon is not allowed to access file:// URLs so this is not possible for security reasons.

I haven't got access to the browser console as I'm running it on my android, but according to this it should be possible in theory

The link you've given is just a draft for discussion about local file access.
The same page also has this:

Not planned
...
Access to file:// URLs or reading files without any explicit user input

For testing, it actually is possible to install my Addon to a Desktop Firefox to get a browser console. I did so and get the following error message:

Security Error: Content at moz-extension://xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/content/web/viewer.html?file=file%3A%2F%2F%2Fhome%2Ftest%2Ftest.pdf may not load or link to file:///home/test/test.pdf.

So for short: It is not possible to access file:// URL's this way.

It would be possible to view local files if I offer a file upload dialog so the user has to explicitly select the file he wants to view. But this doesn't belong into my Addon as every website could do so, too.

commented

Actually you can open local files and it works currently, then I'll tell you how to:

  1. open an online pdf file, it will open the extension
  2. open two arrows >>
  3. click on "open"
  4. It will open your file explorer, select a file

That's it!

@B0pol doesn't work (in current version) unfortunately... results in

Unexpected server response
PDF.js v2.8.335 (build: 228adbf67)
Message: Unexpected server response (0) while retrieving PDF

could it be done using this add on? redirector
i tried but didnt get anywhere...

Please don't do such discussion in closed issues! The issue with the "Open File" button is noted here now: #22

In future: Please open new issues and don't discuss new stuff on issues that are already closed.