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

#page=N anchors not working

jtotht opened this issue · comments

Hi! Thanks for this extension, it’s really more convenient than downloading everything! However, there’s a (probably rather rarely used) function of PDF.js that doesn’t work in the extension: page anchors. In desktop Firefox, if I open https://epa.oszk.hu/00800/00861/00032/pdf/02_kristo.pdf#page=2, it goes straight to page 2. In your extension it doesn’t, because the anchor gets URL-encoded with the rest of the URL when navigating to the extension page. It should be cut off the URL and put back after encoding in order to work.

I've reworked the whole function for viewer URL generation. This also includes a (hard coded) setting for pagemode to get rid of the (sometimes) automatically displaying sidebar which has to be hidden on mobile in most cases to have enough space to view the PDF.

Thanks! I wonder whether any other hash options make sense to be forwarded. (Is there an exhaustive list of supported options apart from “use the source look”?) Also I think the pagemode should be an (opt-out) setting, as this addon may be used on tablets as well, where there may be enough space the sidebar.

I've already added a second parameter. I don't think that there are more that are supported by PDF.js and make sense to be forwarded.

You can still open the sidebar manually.
The setting just disallows PDF files to define that it has to be opened when loading the PDF file.

I think forcing defaults without a good reason causes bad UX. On tablets (which are more convenient for PDF reading anyway because of the much larger space) there’s no good reason to forcibly hide the sidebar. Providing a choice doesn’t hurt, and it’s pretty easy to implement.

But the same goes for PDF files. They should not be able to forcefully open the sidebar

I don’t know under what circumstances the sidebar opens, but I trust Mozilla to make decisions about PDF.js with proper UX background. They’re a big organization enough to be able to afford paying for UX designers, researches, A/B tests etc. You won’t conduct A/B tests, 500 users are simply not enough for that.

As far as I know the PDF tells if the sidebar should be opened. But I didn't have a deeper look at the PDF.js source code. Some PDFs with table of contents load with the sidebar open and some don't so it has to be some metadate in the PDF. On Android I prefer to only have the green identifier on the "sidebar button" so I decide if I want to have the table of contents open or not.

This could be made configurable but this would require additional permissions (so far this Addon does not have the "storage" permission) and would also need some additional code to save the setting. Could be added in future but not with priority.

Edit: I have the storage permission. I forgot the cache that I need. But there is still some work needed to make this configurable.

I had a look at both, the PDF standard and the PDF.js source code today and in fact it's the PDF file which is telling to open the sidebar. I don't think that this is useful on smaller devices in most cases. I kept closing the sidebar when opening such PDF files as it wastes too much space.

But I'll keep in mind that it may be useful to add a config option for this at some point.