diff --git a/src/display/display_utils.js b/src/display/display_utils.js index f8cfd5b69..3be6ba021 100644 --- a/src/display/display_utils.js +++ b/src/display/display_utils.js @@ -245,13 +245,16 @@ class PageViewport { rotateC = -1; rotateD = 0; break; - // case 0: - default: + case 0: rotateA = 1; rotateB = 0; rotateC = 0; rotateD = -1; break; + default: + throw new Error( + "PageViewport: Invalid rotation, must be a multiple of 90 degrees." + ); } if (dontFlip) { diff --git a/test/unit/api_spec.js b/test/unit/api_spec.js index 90976ab53..27e9ad6cc 100644 --- a/test/unit/api_spec.js +++ b/test/unit/api_spec.js @@ -1427,6 +1427,16 @@ describe("api", function () { expect(viewport.transform).toEqual([1, 0, 0, -1, 0, 841.89]); expect(dontFlipViewport.transform).toEqual([1, 0, -0, 1, 0, 0]); }); + it("gets viewport with invalid rotation", function () { + expect(function () { + page.getViewport({ scale: 1, rotation: 45 }); + }).toThrow( + new Error( + "PageViewport: Invalid rotation, must be a multiple of 90 degrees." + ) + ); + }); + it("gets annotations", function (done) { var defaultPromise = page.getAnnotations().then(function (data) { expect(data.length).toEqual(4);