|
|
@ -1695,10 +1695,19 @@ |
|
|
|
var self = this; |
|
|
|
var self = this; |
|
|
|
var goToDestination = function (destRef) { |
|
|
|
var goToDestination = function (destRef) { |
|
|
|
// dest array looks like that: <page-ref> </XYZ|/FitXXX> <args..>
|
|
|
|
// dest array looks like that: <page-ref> </XYZ|/FitXXX> <args..>
|
|
|
|
var pageNumber = destRef instanceof Object ? self._pagesRefCache[destRef.num + ' ' + destRef.gen + ' R'] : destRef + 1; |
|
|
|
var pageNumber; |
|
|
|
|
|
|
|
if (destRef instanceof Object) { |
|
|
|
|
|
|
|
pageNumber = self._cachedPageNumber(destRef); |
|
|
|
|
|
|
|
} else if ((destRef | 0) === destRef) { |
|
|
|
|
|
|
|
// Integer
|
|
|
|
|
|
|
|
pageNumber = destRef + 1; |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
console.error('PDFLinkService_navigateTo: "' + destRef + '" is not a valid destination reference.'); |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
if (pageNumber) { |
|
|
|
if (pageNumber) { |
|
|
|
if (pageNumber > self.pagesCount) { |
|
|
|
if (pageNumber < 1 || pageNumber > self.pagesCount) { |
|
|
|
console.error('PDFLinkService_navigateTo: ' + 'Trying to navigate to a non-existent page.'); |
|
|
|
console.error('PDFLinkService_navigateTo: "' + pageNumber + '" is a non-existent page number.'); |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
self.pdfViewer.scrollPageIntoView({ |
|
|
|
self.pdfViewer.scrollPageIntoView({ |
|
|
@ -1715,10 +1724,11 @@ |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
self.pdfDocument.getPageIndex(destRef).then(function (pageIndex) { |
|
|
|
self.pdfDocument.getPageIndex(destRef).then(function (pageIndex) { |
|
|
|
var pageNum = pageIndex + 1; |
|
|
|
self.cachePageRef(pageIndex + 1, destRef); |
|
|
|
var cacheKey = destRef.num + ' ' + destRef.gen + ' R'; |
|
|
|
|
|
|
|
self._pagesRefCache[cacheKey] = pageNum; |
|
|
|
|
|
|
|
goToDestination(destRef); |
|
|
|
goToDestination(destRef); |
|
|
|
|
|
|
|
}).catch(function () { |
|
|
|
|
|
|
|
console.error('PDFLinkService_navigateTo: "' + destRef + '" is not a valid page reference.'); |
|
|
|
|
|
|
|
return; |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
@ -1732,9 +1742,9 @@ |
|
|
|
destinationPromise.then(function (destination) { |
|
|
|
destinationPromise.then(function (destination) { |
|
|
|
dest = destination; |
|
|
|
dest = destination; |
|
|
|
if (!(destination instanceof Array)) { |
|
|
|
if (!(destination instanceof Array)) { |
|
|
|
|
|
|
|
console.error('PDFLinkService_navigateTo: "' + destination + '" is not a valid destination array.'); |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
// invalid destination
|
|
|
|
|
|
|
|
goToDestination(destination[0]); |
|
|
|
goToDestination(destination[0]); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}, |
|
|
|
}, |
|
|
@ -1924,6 +1934,10 @@ |
|
|
|
cachePageRef: function PDFLinkService_cachePageRef(pageNum, pageRef) { |
|
|
|
cachePageRef: function PDFLinkService_cachePageRef(pageNum, pageRef) { |
|
|
|
var refStr = pageRef.num + ' ' + pageRef.gen + ' R'; |
|
|
|
var refStr = pageRef.num + ' ' + pageRef.gen + ' R'; |
|
|
|
this._pagesRefCache[refStr] = pageNum; |
|
|
|
this._pagesRefCache[refStr] = pageNum; |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
_cachedPageNumber: function PDFLinkService_cachedPageNumber(pageRef) { |
|
|
|
|
|
|
|
var refStr = pageRef.num + ' ' + pageRef.gen + ' R'; |
|
|
|
|
|
|
|
return this._pagesRefCache && this._pagesRefCache[refStr] || null; |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|
function isValidExplicitDestination(dest) { |
|
|
|
function isValidExplicitDestination(dest) { |
|
|
|