mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-21 15:48:06 +02:00
Merge pull request #9586 from Snuffleupagus/pageSize-api-rotate
Ensure that `PDFPageProxy.pageSizeInches` handles non-default /Rotate entries correctly
This commit is contained in:
commit
5c1a16ba6e
5 changed files with 56 additions and 25 deletions
|
@ -980,14 +980,6 @@ 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);
|
||||
|
|
|
@ -14,8 +14,8 @@
|
|||
*/
|
||||
|
||||
import {
|
||||
binarySearchFirstItem, EventBus, getPDFFileNameFromURL, isValidRotation,
|
||||
waitOnEventOrTimeout, WaitOnType
|
||||
binarySearchFirstItem, EventBus, getPageSizeInches, getPDFFileNameFromURL,
|
||||
isValidRotation, waitOnEventOrTimeout, WaitOnType
|
||||
} from '../../web/ui_utils';
|
||||
import { createObjectURL } from '../../src/shared/util';
|
||||
import isNodeJS from '../../src/shared/is_node';
|
||||
|
@ -398,4 +398,32 @@ describe('ui_utils', function() {
|
|||
}, done.fail);
|
||||
});
|
||||
});
|
||||
|
||||
describe('getPageSizeInches', function () {
|
||||
it('gets page size (in inches)', function() {
|
||||
const page = {
|
||||
view: [0, 0, 595.28, 841.89],
|
||||
userUnit: 1.0,
|
||||
rotate: 0,
|
||||
};
|
||||
const { width, height, } = getPageSizeInches(page);
|
||||
|
||||
expect(+width.toPrecision(3)).toEqual(8.27);
|
||||
expect(+height.toPrecision(4)).toEqual(11.69);
|
||||
});
|
||||
|
||||
it('gets page size (in inches), for non-default /Rotate entry', function() {
|
||||
const pdfPage1 = { view: [0, 0, 612, 792], userUnit: 1, rotate: 0, };
|
||||
const { width: width1, height: height1, } = getPageSizeInches(pdfPage1);
|
||||
|
||||
expect(width1).toEqual(8.5);
|
||||
expect(height1).toEqual(11);
|
||||
|
||||
const pdfPage2 = { view: [0, 0, 612, 792], userUnit: 1, rotate: 90, };
|
||||
const { width: width2, height: height2, } = getPageSizeInches(pdfPage2);
|
||||
|
||||
expect(width2).toEqual(11);
|
||||
expect(height2).toEqual(8.5);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue