Configuration:
//mozilla.github.io/pdf.js/build/pdf.js
)Steps to reproduce the problem:
1. include via
- <script src="//mozilla.github.io/pdf.js/build/pdf.js"></script>
2. set:
- pdfjsLib.GlobalWorkerOptions.workerSrc = '//mozilla.github.io/pdf.js/build/pdf.worker.js';
3. use examples from: https://mozilla.github.io/pdf.js/examples/
What went wrong? (add screenshot)
The examples have already been updated with this new API usage, just not yet on JSFiddle. @yurydelendik Could you perhaps update all examples on that page with the current code from the examples
folder?
Fixed
Came here because I was getting this error when upgrading from v1 to v2:
Deprecated API usage: PDFDocumentLoadingTask.then method, use the `promise` getter instead.
In short, we now have to explicitly refer to .promise
//V1
const loadPDF = await PDFJS.getDocument(file);
const pages = loadPDF.numPages;
//V2
const loadPDF = await PDFJS.getDocument(file).promise; //<-- simply change it here
const pages = loadPDF.numPages;
the view port error is die to using version 1 way:
var viewport = pdfPage.getViewport(scale, rotate);
change it to use GetViewportParameters :
https://github.com/mozilla/pdf.js/blob/master/src/display/api.js#L158
var viewport = pdfPage.getViewport({scale:scale, rotate:rotate});
Most helpful comment
Came here because I was getting this error when upgrading from v1 to v2:
In short, we now have to explicitly refer to
.promise