mozilla / pdf.js

PDF Reader in JavaScript
https://mozilla.github.io/pdf.js/
Apache License 2.0
47.14k stars 9.82k forks source link

"Fit Width" does not work properly with documents that have mixed page orientations / aspect ratios #18240

Open nekohayo opened 2 weeks ago

nekohayo commented 2 weeks ago

Attach (recommended) or Link to PDF file here: sample file

This is a typical mixed-page-orientations document that you'd encounter in public sector documents featuring architectural plans or spreadsheets landscape pages along with regular portrait-oriented text pages.


Configuration:

Steps to reproduce the problem:

  1. Open the linked sample
  2. Set zoom mode to "Fit Width"
  3. Notice the 2nd page is cut-off because it is not shrunk to width
  4. Scroll to the 2nd page, Ctrl+R to reload
  5. Notice the 1st page is now shrunk below half of the canvas width, instead of being full width

What is the expected behavior?

Each page should fit to width.

I suppose that behind the scenes, the zoom should be applied to individual pages rather than globally to the document. In the video shown in https://gitlab.gnome.org/GNOME/Incubator/papers/-/issues/161#note_2139951 you can see that LibreOffice Writer and Okular take different approaches to solve the problem: Writer adjusts the global zoom when you focus (click) the page in question, whereas Okular just sets the zoom for each page individually to fit the width.