Zoom parameter implemented "upside-down"
See original GitHub issueAccording to the open parameter specification, link, the zoom parameter should be implemented as: zoom=scale,left,top
, with the interpretation:
Scroll values left and top are in a coordinate system where 0,0 represents the top left corner of the visible page, regardless of document rotation.
This is not the case in pdf.js, which is a problem if you try opening the following: http://mozilla.github.io/pdf.js/web/viewer.html#page=2&zoom=auto,0,0
- Expected result: The document should open at the top of page 2, as it does with Adobe Reader.
- What actually happens: The document is scrolled down to the top of page 3.
The problem seems to be that in pdf.js the origin in the coordinate system (the one that is exposed to the user) is placed at the bottom left corner. From what I’ve gathered, pdf.js internally uses a coordinate system placed at the top left corner of the page, so I don’t know why it’s not working. I’m not that familiar with this part of the codebase, but could the issue be here: https://github.com/mozilla/pdf.js/blob/master/src/util.js#L390
This issue might be related to issues involving links pointing to the wrong place in PDFs, e.g. #2814, #2401, #2151, since all those files contains links that also applies a rescaling to “page-fit”. I’m guessing that what happens is that the zoom is set to zoom=page-fit,0,0
, which clearly isn’t working.
Issue Analytics
- State:
- Created 11 years ago
- Reactions:1
- Comments:17 (7 by maintainers)
Top GitHub Comments
I’ve been looking into this issue a bit, and I agree with @Snuffleupagus 's comment. Currently, PDF JS interprets the zoom parameter value of PDF URL fragments according to the definition of the “user space” coordinate system in the PDF Reference (1.7):
It should instead be using the coordinate system defined by the open parameters document:
Before the code in
web/pdf_link_service.js
callsBaseViewer.scrollPageIntoView
, there should be a transformation from the “open parameters” coordinate system to the “user space” coordinate system.The top of the page of the spec for the
zoom
parameter by adobe (for pdf.js users)For any other users, the preceding will show the bottom of the page.
The top of the page of the spec for the
zoom
parameter by adobe (for any other users: chrome, explorer or acrobat)For
pdf.js
users, the preceding will show the bottom of the page.Note that both cases won’t reach the same bottom which would mean that there is an issue with the scale of the vertical component of the coordinate system as well…