Skip to content
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

Merged
merged 4 commits into from Mar 18, 2018

Conversation

Snuffleupagus
Copy link
Collaborator

@Snuffleupagus Snuffleupagus commented Mar 17, 2018

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.

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.
@mozilla mozilla deleted a comment from pdfjsbot Mar 18, 2018
@mozilla mozilla deleted a comment from pdfjsbot Mar 18, 2018
@mozilla mozilla deleted a comment from pdfjsbot Mar 18, 2018
@mozilla mozilla deleted a comment from pdfjsbot Mar 18, 2018
@timvandermeij
Copy link
Contributor

/botio-linux preview

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Received

Command cmd_preview from @timvandermeij received. Current queue size: 0

Live output at: http://54.67.70.0:8877/bbcc801b678897f/output.txt

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Success

Full output at http://54.67.70.0:8877/bbcc801b678897f/output.txt

Total script time: 2.79 mins

Published

@timvandermeij
Copy link
Contributor

/botio unittest

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Received

Command cmd_unittest from @timvandermeij received. Current queue size: 0

Live output at: http://54.67.70.0:8877/a9260d8ca4e857a/output.txt

@pdfjsbot
Copy link

From: Bot.io (Windows)


Received

Command cmd_unittest from @timvandermeij received. Current queue size: 0

Live output at: http://54.215.176.217:8877/7c685629a1afbd6/output.txt

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Success

Full output at http://54.67.70.0:8877/a9260d8ca4e857a/output.txt

Total script time: 2.95 mins

  • Unit Tests: Passed

@pdfjsbot
Copy link

From: Bot.io (Windows)


Success

Full output at http://54.215.176.217:8877/7c685629a1afbd6/output.txt

Total script time: 6.82 mins

  • Unit Tests: Passed

@timvandermeij timvandermeij merged commit 0d391da into mozilla:master Mar 18, 2018
@timvandermeij
Copy link
Contributor

Awesome; thank you for fixing this!

@Snuffleupagus Snuffleupagus deleted the pagesize-info-fixes branch March 18, 2018 15:01
movsb pushed a commit to movsb/pdf.js that referenced this pull request Jul 14, 2018
[api-minor] Fix various issues related to pageSize, and display the size for the active page in the document properties dialog
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants