initialBookmark doesn't work as expected, possible regression from #2914 #3068

Closed
Snuffleupagus opened this Issue Apr 9, 2013 · 2 comments

Comments

Projects
None yet
2 participants
Member

Snuffleupagus commented Apr 9, 2013

It appears that specifying a destination in the hash when loading a PDF file no longer works as it used to. For example, try opening: http://mirrors.ctan.org/info/lshort/english/lshort.pdf#section.1.1. You expect to be taken straight to section 1.1 when the document loads, but instead page 1 will be shown.

I've found that the issue seems to be that when the document is loaded, pagesRefMap hasn't been initialized yet, which causes the pageNumber lookup to fail here: https://github.com/mozilla/pdf.js/blob/master/web/viewer.js#L1182

This used to work, but I haven't tried to find the exact regression range, but as far as I know the only recent PR that touched code relating to pagesRefMap is #2914.

@mduan Is it possible that #2914 caused this? If that is the case, can it be fixed?

Member

Snuffleupagus commented Apr 19, 2013

I have found that after #2719 was merged, specifying a destination as initialBookmark will instead fail at: https://github.com/mozilla/pdf.js/blob/master/web/viewer.js#L1176. The reason is that with progressive loading, PDFView.destinations doesn't exist yet, when it's called from the navigateTo function. This makes perfect sense to me, but causes a less than perfect user experience.

I've taken a stab at implementing a workaround for this issue. It seems to be working as it should in my testing, but might not be the most optimal solution. It is currently available here: Snuffleupagus/pdf.js@8a9baa3.
If this workaround is sufficiently good, I would be happy to submit a PR.

Contributor

mduan commented Apr 23, 2013

Fixed by PR above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment