diff --git a/web/app.js b/web/app.js index cbb20755a..adea7ca2f 100644 --- a/web/app.js +++ b/web/app.js @@ -1149,7 +1149,7 @@ const PDFViewerApplication = { this.pdfViewer.setDocument(null); this.pdfLinkService.setDocument(null); this.pdfDocumentProperties?.setDocument(null); - this.pdfTextExtractor?.setDocument(null); + this.pdfTextExtractor?.setViewer(null); } this.pdfLinkService.externalLinkEnabled = true; this.store = null; diff --git a/web/pdf_text_extractor.js b/web/pdf_text_extractor.js index f8bbbb609..630e8d5b0 100644 --- a/web/pdf_text_extractor.js +++ b/web/pdf_text_extractor.js @@ -50,7 +50,7 @@ class PdfTextExtractor { for (const pendingRequest of this.#pendingRequests) { this.extractTextContent(pendingRequest); } - this.#pendingRequests = new Set(); + this.#pendingRequests.clear(); } } @@ -66,8 +66,7 @@ class PdfTextExtractor { } if (!this.#textPromise) { - const textPromise = this.#pdfViewer.getAllText(); - this.#textPromise = textPromise; + const textPromise = (this.#textPromise = this.#pdfViewer.getAllText()); // After the text resolves, cache the text for a little bit in case // multiple consumers call it.