Merge pull request #9099 from tiriana/allow-dontFlip-in-PDFPageProxy-getViewport
Allows 'dontFlip' as third arg in PDFPageProxy.getViewport
This commit is contained in:
commit
915e3f4c5f
@ -781,14 +781,12 @@ var PDFPageProxy = (function PDFPageProxyClosure() {
|
||||
* @param {number} scale The desired scale of the viewport.
|
||||
* @param {number} rotate Degrees to rotate the viewport. If omitted this
|
||||
* defaults to the page rotation.
|
||||
* @param {boolean} dontFlip (optional) If true, axis Y will not be flipped.
|
||||
* @return {PageViewport} Contains 'width' and 'height' properties
|
||||
* along with transforms required for rendering.
|
||||
*/
|
||||
getViewport: function PDFPageProxy_getViewport(scale, rotate) {
|
||||
if (arguments.length < 2) {
|
||||
rotate = this.rotate;
|
||||
}
|
||||
return new PageViewport(this.view, scale, rotate, 0, 0);
|
||||
getViewport(scale, rotate = this.rotate, dontFlip = false) {
|
||||
return new PageViewport(this.view, scale, rotate, 0, 0, dontFlip);
|
||||
},
|
||||
/**
|
||||
* @param {GetAnnotationsParameters} params - Annotation parameters.
|
||||
|
@ -979,6 +979,18 @@ describe('api', function() {
|
||||
expect(viewport.width).toEqual(1262.835);
|
||||
expect(viewport.height).toEqual(892.92);
|
||||
});
|
||||
it('gets viewport respecting "dontFlip" argument', function () {
|
||||
const scale = 1;
|
||||
const rotation = 135;
|
||||
let viewport = page.getViewport(scale, rotation);
|
||||
let dontFlipViewport = page.getViewport(scale, rotation, true);
|
||||
|
||||
expect(dontFlipViewport).not.toEqual(viewport);
|
||||
expect(dontFlipViewport).toEqual(viewport.clone({ dontFlip: true, }));
|
||||
|
||||
expect(viewport.transform).toEqual([1, 0, 0, -1, 0, 841.89]);
|
||||
expect(dontFlipViewport.transform).toEqual([1, 0, -0, 1, 0, 0]);
|
||||
});
|
||||
it('gets annotations', function (done) {
|
||||
var defaultPromise = page.getAnnotations().then(function (data) {
|
||||
expect(data.length).toEqual(4);
|
||||
|
Loading…
Reference in New Issue
Block a user