question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

#pageN anchor not working on first page load

See original GitHub issue

Attach (recommended) or Link to PDF file here: https://epa.oszk.hu/00800/00861/00032/pdf/02_kristo.pdf#page2

Configuration:

  • Web browser and its version: Firefox ESR 68.4.1 & Developer Edition 73.0b3
  • Operating system and its version: Debian 9 “stretch”
  • PDF.js version: 2.2.178, 2.4.254 (the ones built in these versions of Firefox)
  • Is a browser extension: no, core Firefox

Steps to reproduce the problem:

  1. Open the above link

What is the expected behavior? The PDF opens with page 2. PDF showing second page

What went wrong? The PDF opens with page 1. PDF showing first page

Link to a viewer (if hosted on a site other than mozilla.github.io/pdf.js or as Firefox/Chrome extension): N/A

Additional details: The function works after page load (when I enter a different anchor name in the URL bar, Firefox goes straight there, without reloading the page; that’s OK). When the anchor is present in the URL on page load, the following error pops up on the browser console:

PDFLinkService.navigateTo: "null" is not a valid destination array, for dest="page2". viewer.js:6570:17

(the line number is 6507 in v2.2.178, otherwise the same error message). No further stack trace is provided.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7

github_iconTop GitHub Comments

1reaction
Snuffleupaguscommented, Jan 10, 2020

Maybe this issue can be repurposed to track the removal of this undocumented feature from PDF.js?

That was my intention, but some quick debugging would suggest that there’s no bug in PDF.js and rather that the browser itself is somehow “helpfully” interpreting those incorrect hashes. That’s based on the fact that this only works for pages that have already been loaded/rendered, and if the PDF.js logic was actually invoked it would work for every page (as the #page=n format does).

I’m thoroughly confused now…

Edit: And it even works the exact same way in the simpleviewer example, see https://github.com/mozilla/pdf.js/tree/master/examples/components, and that one doesn’t even contain any code for handling URLs/hashes at all.

0reactions
Snuffleupaguscommented, Jan 11, 2020

There’s something that seems to be in connection with this in web/pdf_page_view.js, L78,

That property is only used in a JavaScript object, and not actually appended to the DOM. The actual error rather seems to stem from this line, which we’ll have to look into changing/removing in some way.

As PDF.js targets only HTML5-compliant browsers anyway, maybe page=N could be used as actual HTML ID? I don’t know whether this confuses the JS code responsible for navigation.

That would end up “fighting” with the general PDF.js navigation, as you suspected, and there’s also the issue of that only working for loaded/rendered pages. Hence preventing this browser navigation from working really seem like the best solution.


Anyway, thanks for helping out with getting to the bottom of all of this!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Deadman's Angle Revisited - Dr. Eric Strauss
The current investigation evaluated the effect that the angle of screw-in suture anchor insertion has on fixation stability at the suture–tendon interface in....
Read more >
How to add css class to a active in-page-link (hashtag link)
I believe that is only possible by Retrieve the client resolution via window.innerWidth/window.innerHeight and then using mouse event such ...
Read more >
Biomechanical comparison between single-row with triple ...
Biomechanical comparison between single-row with triple-loaded suture anchor and suture-bridge double-row rotator cuff repair.
Read more >
All-Suture Anchors: Biomechanical Analysis of Pullout ...
The ultimate failure load of an all-suture anchor is correlated directly with its number of sutures. With cyclic loading, the Y-Knot ...
Read more >
Issues with custom beamer theme - LaTeX Stack Exchange
A \rule command will do the work. ... Title page background \node[anchor=north west,inner sep=0pt,minimum ... page header} \rule{.5pt}{4cm}\ ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found