Merge pull request #4322 from prometheansacrifice/FixUnhandledExistingPageBug

Attempting to fix #4166
This commit is contained in:
Yury Delendik 2014-02-23 16:01:54 -06:00
commit f11a6ae238

View File

@ -726,6 +726,7 @@ var WorkerTransport = (function WorkerTransportClosure() {
messageHandler.on('GetDoc', function transportDoc(data) {
var pdfInfo = data.pdfInfo;
this.numPages = data.pdfInfo.numPages;
var pdfDocument = new PDFDocumentProxy(pdfInfo, this);
this.pdfDocument = pdfDocument;
this.workerReadyPromise.resolve(pdfDocument);
@ -930,6 +931,13 @@ var WorkerTransport = (function WorkerTransportClosure() {
},
getPage: function WorkerTransport_getPage(pageNumber, promise) {
if (pageNumber <= 0 || pageNumber > this.numPages ||
(pageNumber|0) !== pageNumber) {
var pagePromise = new PDFJS.LegacyPromise();
pagePromise.reject(new Error('Invalid page request'));
return pagePromise;
}
var pageIndex = pageNumber - 1;
if (pageIndex in this.pagePromises)
return this.pagePromises[pageIndex];