New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[api-minor] Fix various issues related to pageSize, and display the size for the active page in the document properties dialog #9577
[api-minor] Fix various issues related to pageSize, and display the size for the active page in the document properties dialog #9577
Conversation
The `getPageSizeInches` method was implemented on `PDFDocumentProxy`, which seems conceptually wrong since the size property isn't global to the document but rather specific to each page. Hence the method is moved into `PDFPageProxy`, as `get pageSizeInches` instead to address this. Despite the fact that new API functionality was implemented, no unit-tests were added. To prevent issues later on, we should *always* ensure that new functionality has at least some test-coverage; something that this patch also takes care of. The new `PDFDocumentProperties._parsePageSize` method seemed unnecessary convoluted. Furthermore, in the "no data provided"-case it even returned incorrect data (an array, rather than the expected object). Finally, the fallback strings didn't actually agree with the `en-US` locale. This inconsistency doesn't look too great, and it's thus addressed here as well.
The units are currently repeated after each dimension, which seems unnecessary and is also not done in other PDF viewers (such as e.g. Adobe Reader). Furthermore, the name of the l10n arguments can be simplified slightly, since the name of the strings themselves should be enough information. Finally, the `width`/`height` should be formatted according to the current locale, as is already done for other strings in the document properties dialog.
…ialog, when it's already been correctly set
/botio-linux preview |
From: Bot.io (Linux m4)ReceivedCommand cmd_preview from @timvandermeij received. Current queue size: 0 Live output at: http://54.67.70.0:8877/bbcc801b678897f/output.txt |
From: Bot.io (Linux m4)SuccessFull output at http://54.67.70.0:8877/bbcc801b678897f/output.txt Total script time: 2.79 mins Published |
/botio unittest |
From: Bot.io (Linux m4)ReceivedCommand cmd_unittest from @timvandermeij received. Current queue size: 0 Live output at: http://54.67.70.0:8877/a9260d8ca4e857a/output.txt |
From: Bot.io (Windows)ReceivedCommand cmd_unittest from @timvandermeij received. Current queue size: 0 Live output at: http://54.215.176.217:8877/7c685629a1afbd6/output.txt |
From: Bot.io (Linux m4)SuccessFull output at http://54.67.70.0:8877/a9260d8ca4e857a/output.txt Total script time: 2.95 mins
|
From: Bot.io (Windows)SuccessFull output at http://54.215.176.217:8877/7c685629a1afbd6/output.txt Total script time: 6.82 mins
|
Awesome; thank you for fixing this! |
[api-minor] Fix various issues related to pageSize, and display the size for the active page in the document properties dialog
Glancing quickly at the recent implementation of pageSize, for the document properties dialog, there were a couple of things that seemed to benefit from some refactoring; please see the commit messages for details.
Edit: Can be tested with e.g. https://github.com/mozilla/pdf.js/blob/master/test/pdfs/sizes.pdf.