From 8fa5fcfe72855c0f79ef469f09fa8b2f84208130 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Fri, 26 Nov 2021 20:21:12 +0100 Subject: [PATCH] [Regression] Prevent errors, during loading, in the viewer for XFA-documents (PR 14295 follow-up) In the second commit in PR 14295, I forgot that the pages in XFA-documents don't have references (like in regular PDF documents); sorry about that! --- web/pdf_link_service.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/web/pdf_link_service.js b/web/pdf_link_service.js index 4286f2e3a..b5732ffe3 100644 --- a/web/pdf_link_service.js +++ b/web/pdf_link_service.js @@ -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;