missing support for "view" parameter in URL fragment identifiers
See original GitHub issueAccording to Parameters for Opening PDF Files (version 9.0) (and referenced in RFC 8118):
view=Fit view=FitH view=FitH,top view=FitV view=FitV,left view=FitB view=FitBH view=FitBH,top view=FitBV view=FitBV,left
Set the view of the displayed page, using the keyword values defined in the PDF language specification. For more information, see the PDF Reference. Scroll values left and top are floats or integers in a coordinate system where 0,0 represents the top left corner of the visible page, regardless of document rotation.
It appears that the view
parameter in PDF URL fragment identifiers is currently unsupported. To verify, I tested as follows:
Configuration:
- Web browser and its version: Firefox Quantum 66.0.3 (64-bit)
- Operating system and its version: GNU/Linux x86_64
- PDF.js version: https://github.com/mozilla/pdf.js/tree/762c58e0fcfdc8f3fd23ce22a15ee044d8d372ec
- Is a browser extension: no
Steps to reproduce the problem:
- Check out the repository, run
npm install
andgulp server
, then navigate the viewer to a PDF that isn’t automatically zoomed in to fill your viewport width on viewer initialization (http://localhost:8888/web/viewer.html?file=%2Ftest%2Fpdfs%2Ftracemonkey.pdf works for me). - Append
#page=1&view=FitH
to the URL in the address bar, and reload the page.
What is the expected behavior?
The viewer should set the zoom level so that the PDF fills the entire width of the viewport.
What went wrong?
The viewport was not transformed as expected.
It looks like the problem is mainly with PDFLinkService.setHash
. There is no check for the view
parameter.
Interestingly enough, Fit*
values are being checked for in the zoom
parameter, but I’m having trouble understanding why (since none of RFC 3778, RFC 8118, or the PDF Open Parameters document say that those are vallid values for zoom
). The deepest I was able to dig was this PR, but it looks like Fit*
values have been handled this way even before that.
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (1 by maintainers)
Top GitHub Comments
Hello, I am working on a project for a software course and I would love to work on this. I noticed that the Fit* values work for the
zoom
parameter. I want to make sure that adding support for these values for theview
parameter is still a desired feature. If so, I would appreciate any additional information anyone has on this since it is my first time contributing to a public Open-Source project. Thank you.@timvandermeij, as you suggested, I think the values from
view
andzoom
may be split such as in:If this is right (I have basically copied and pasted text), I don’t mind to submit a PR. But consider that I cannot code properly (very basic Lua exposure and no proper JavaScript).
Many thanks for your help.