|
|
@ -713,58 +713,71 @@ var PDFLinkService = function PDFLinkServiceClosure() { |
|
|
|
set page(value) { |
|
|
|
set page(value) { |
|
|
|
this.pdfViewer.currentPageNumber = value; |
|
|
|
this.pdfViewer.currentPageNumber = value; |
|
|
|
}, |
|
|
|
}, |
|
|
|
navigateTo: function PDFLinkService_navigateTo(dest) { |
|
|
|
navigateTo: function navigateTo(dest) { |
|
|
|
var destString = ''; |
|
|
|
var _this = this; |
|
|
|
var self = this; |
|
|
|
|
|
|
|
var goToDestination = function goToDestination(destRef) { |
|
|
|
var goToDestination = function goToDestination(_ref) { |
|
|
|
var pageNumber; |
|
|
|
var namedDest = _ref.namedDest, |
|
|
|
|
|
|
|
explicitDest = _ref.explicitDest; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var destRef = explicitDest[0], |
|
|
|
|
|
|
|
pageNumber = void 0; |
|
|
|
if (destRef instanceof Object) { |
|
|
|
if (destRef instanceof Object) { |
|
|
|
pageNumber = self._cachedPageNumber(destRef); |
|
|
|
pageNumber = _this._cachedPageNumber(destRef); |
|
|
|
|
|
|
|
if (pageNumber === null) { |
|
|
|
|
|
|
|
_this.pdfDocument.getPageIndex(destRef).then(function (pageIndex) { |
|
|
|
|
|
|
|
_this.cachePageRef(pageIndex + 1, destRef); |
|
|
|
|
|
|
|
goToDestination({ |
|
|
|
|
|
|
|
namedDest: namedDest, |
|
|
|
|
|
|
|
explicitDest: explicitDest |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
}).catch(function () { |
|
|
|
|
|
|
|
console.error('PDFLinkService.navigateTo: "' + destRef + '" is not ' + ('a valid page reference, for dest="' + dest + '".')); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
} else if ((destRef | 0) === destRef) { |
|
|
|
} else if ((destRef | 0) === destRef) { |
|
|
|
pageNumber = destRef + 1; |
|
|
|
pageNumber = destRef + 1; |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
console.error('PDFLinkService_navigateTo: "' + destRef + '" is not a valid destination reference.'); |
|
|
|
console.error('PDFLinkService.navigateTo: "' + destRef + '" is not ' + ('a valid destination reference, for dest="' + dest + '".')); |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
if (pageNumber) { |
|
|
|
if (!pageNumber || pageNumber < 1 || pageNumber > _this.pagesCount) { |
|
|
|
if (pageNumber < 1 || pageNumber > self.pagesCount) { |
|
|
|
console.error('PDFLinkService.navigateTo: "' + pageNumber + '" is not ' + ('a valid page number, for dest="' + dest + '".')); |
|
|
|
console.error('PDFLinkService_navigateTo: "' + pageNumber + '" is a non-existent page number.'); |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
_this.pdfViewer.scrollPageIntoView({ |
|
|
|
self.pdfViewer.scrollPageIntoView({ |
|
|
|
pageNumber: pageNumber, |
|
|
|
pageNumber: pageNumber, |
|
|
|
destArray: explicitDest |
|
|
|
destArray: dest |
|
|
|
}); |
|
|
|
|
|
|
|
if (_this.pdfHistory) { |
|
|
|
|
|
|
|
_this.pdfHistory.push({ |
|
|
|
|
|
|
|
dest: explicitDest, |
|
|
|
|
|
|
|
hash: namedDest, |
|
|
|
|
|
|
|
page: pageNumber |
|
|
|
}); |
|
|
|
}); |
|
|
|
if (self.pdfHistory) { |
|
|
|
} |
|
|
|
self.pdfHistory.push({ |
|
|
|
}; |
|
|
|
dest: dest, |
|
|
|
new Promise(function (resolve, reject) { |
|
|
|
hash: destString, |
|
|
|
if (typeof dest === 'string') { |
|
|
|
page: pageNumber |
|
|
|
_this.pdfDocument.getDestination(dest).then(function (destArray) { |
|
|
|
|
|
|
|
resolve({ |
|
|
|
|
|
|
|
namedDest: dest, |
|
|
|
|
|
|
|
explicitDest: destArray |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
self.pdfDocument.getPageIndex(destRef).then(function (pageIndex) { |
|
|
|
|
|
|
|
self.cachePageRef(pageIndex + 1, destRef); |
|
|
|
|
|
|
|
goToDestination(destRef); |
|
|
|
|
|
|
|
}).catch(function () { |
|
|
|
|
|
|
|
console.error('PDFLinkService_navigateTo: "' + destRef + '" is not a valid page reference.'); |
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
resolve({ |
|
|
|
var destinationPromise; |
|
|
|
namedDest: '', |
|
|
|
if (typeof dest === 'string') { |
|
|
|
explicitDest: dest |
|
|
|
destString = dest; |
|
|
|
}); |
|
|
|
destinationPromise = this.pdfDocument.getDestination(dest); |
|
|
|
}).then(function (data) { |
|
|
|
} else { |
|
|
|
if (!(data.explicitDest instanceof Array)) { |
|
|
|
destinationPromise = Promise.resolve(dest); |
|
|
|
console.error('PDFLinkService.navigateTo: "' + data.explicitDest + '" is' + (' not a valid destination array, for dest="' + dest + '".')); |
|
|
|
} |
|
|
|
|
|
|
|
destinationPromise.then(function (destination) { |
|
|
|
|
|
|
|
dest = destination; |
|
|
|
|
|
|
|
if (!(destination instanceof Array)) { |
|
|
|
|
|
|
|
console.error('PDFLinkService_navigateTo: "' + destination + '" is not a valid destination array.'); |
|
|
|
|
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
goToDestination(destination[0]); |
|
|
|
goToDestination(data); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}, |
|
|
|
}, |
|
|
|
getDestinationHash: function getDestinationHash(dest) { |
|
|
|
getDestinationHash: function getDestinationHash(dest) { |
|
|
|