Merge pull request #14314 from Snuffleupagus/XFA-viewer-refs-cache-fix

[Regression] Prevent errors, during loading, in the viewer for XFA-documents (PR 14295 follow-up)
This commit is contained in:
Jonas Jenwald 2021-11-26 20:47:45 +01:00 committed by GitHub
commit e439f4d620
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -120,7 +120,7 @@ class PDFLinkService {
if (typeof destRef === "object" && destRef !== null) {
pageNumber = this._cachedPageNumber(destRef);
if (pageNumber === null) {
if (!pageNumber) {
// Fetch the page reference if it's not yet available. This could
// only occur during loading, before all pages have been resolved.
this.pdfDocument
@ -446,6 +446,9 @@ class PDFLinkService {
* @private
*/
_cachedPageNumber(pageRef) {
if (!pageRef) {
return null;
}
const refStr =
pageRef.gen === 0 ? `${pageRef.num}R` : `${pageRef.num}R${pageRef.gen}`;
return this._pagesRefCache?.[refStr] || null;