diff --git a/web/pdf_find_controller.js b/web/pdf_find_controller.js index 75163f685..481b0aa8d 100644 --- a/web/pdf_find_controller.js +++ b/web/pdf_find_controller.js @@ -909,6 +909,11 @@ class PDFFindController { try { const pdfPage = await pdfDoc.getPage(i + 1); const textContent = await pdfPage.getTextContent(textOptions); + + if (pdfDoc !== this._pdfDocument) { + resolve(); + return; + } const strBuf = []; for (const textItem of textContent.items) { @@ -921,6 +926,10 @@ class PDFFindController { [this._pageContents[i], this._pageDiffs[i], this._hasDiacritics[i]] = normalize(strBuf.join("")); } catch (ex) { + if (pdfDoc !== this._pdfDocument) { + resolve(); + return; + } console.error(`Unable to get text content for page ${i + 1}`, ex); // Page error -- assuming no text content. [this._pageContents[i], this._pageDiffs[i], this._hasDiacritics[i]] =