mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-08 01:10:08 +02:00
More robust getPage() error handling.
This commit is contained in:
parent
0c95bc7d83
commit
d0e93721ae
4 changed files with 33 additions and 3 deletions
|
@ -133,10 +133,10 @@ class PDFThumbnailViewer {
|
|||
|
||||
this.pdfDocument = pdfDocument;
|
||||
if (!pdfDocument) {
|
||||
return Promise.resolve();
|
||||
return;
|
||||
}
|
||||
|
||||
return pdfDocument.getPage(1).then((firstPage) => {
|
||||
pdfDocument.getPage(1).then((firstPage) => {
|
||||
let pagesCount = pdfDocument.numPages;
|
||||
let viewport = firstPage.getViewport(1.0);
|
||||
for (let pageNum = 1; pageNum <= pagesCount; ++pageNum) {
|
||||
|
@ -151,6 +151,8 @@ class PDFThumbnailViewer {
|
|||
});
|
||||
this._thumbnails.push(thumbnail);
|
||||
}
|
||||
}).catch((reason) => {
|
||||
console.error('Unable to initialize thumbnail viewer', reason);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -205,6 +207,10 @@ class PDFThumbnailViewer {
|
|||
thumbView.setPdfPage(pdfPage);
|
||||
this._pagesRequests[pageNumber] = null;
|
||||
return pdfPage;
|
||||
}).catch((reason) => {
|
||||
console.error('Unable to get page for thumb view', reason);
|
||||
// Page error -- there is nothing can be done.
|
||||
this._pagesRequests[pageNumber] = null;
|
||||
});
|
||||
this._pagesRequests[pageNumber] = promise;
|
||||
return promise;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue