Reputation: 165
i'm using pdf.js and all worked fine until yesterday. Now i get this error:
Uncaught (in promise) Error: PDFPageProxy.getViewport is called with obsolete arguments.
at PDFPageProxy.getViewport (api.js:964)
I have set a const for the viewport const viewport = page.getViewport(scale);
/**
* @param {GetViewportParameters} params - Viewport parameters.
* @returns {PageViewport} Contains 'width' and 'height' properties
* along with transforms required for rendering.
*/
getViewport({ scale, rotation = this.rotate, dontFlip = false, } = {}) {
if ((typeof PDFJSDev !== 'undefined' && PDFJSDev.test('GENERIC')) &&
(arguments.length > 1 || typeof arguments[0] === 'number')) {
throw new Error(
'PDFPageProxy.getViewport is called with obsolete arguments.');
}
return new PageViewport({
viewBox: this.view,
scale,
rotation,
dontFlip,
});
}
i don't know what's wrong. p.s. i'm not a js master.
Upvotes: 5
Views: 5231
Reputation: 11273
I'd guess you are passing a number to that method in scale
argument? Like
page.getViewport(1) // this worked before in pre 2.1 versions
It should be an object: try
page.getViewport({scale:1}) // since 2.1 onward
instead. Or in your particular case:
page.getViewport({scale:scale})
Version number this (breaking) change occurred taken from this answer that even points to relevant PR.
Upvotes: 17