mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-21 15:48:06 +02:00
[api-minor] Fix various issues related to the pageSize information
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.
This commit is contained in:
parent
db6e316efd
commit
e0ae157582
3 changed files with 45 additions and 41 deletions
|
@ -964,6 +964,14 @@ describe('api', function() {
|
|||
it('gets view', function () {
|
||||
expect(page.view).toEqual([0, 0, 595.28, 841.89]);
|
||||
});
|
||||
|
||||
it('gets page size (in inches)', function() {
|
||||
const { width, height, } = page.pageSizeInches;
|
||||
|
||||
expect(+width.toPrecision(3)).toEqual(8.27);
|
||||
expect(+height.toPrecision(4)).toEqual(11.69);
|
||||
});
|
||||
|
||||
it('gets viewport', function () {
|
||||
var viewport = page.getViewport(1.5, 90);
|
||||
expect(viewport.viewBox).toEqual(page.view);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue