diff --git a/web/pdf_viewer.js b/web/pdf_viewer.js index 07c476459..780c062be 100644 --- a/web/pdf_viewer.js +++ b/web/pdf_viewer.js @@ -1072,6 +1072,20 @@ class PDFViewer { this._updateSpreadMode(); } + eventBus._on( + "annotationeditorlayerrendered", + evt => { + if (this.#annotationEditorUIManager) { + // Ensure that the Editor buttons, in the toolbar, are updated. + eventBus.dispatch("annotationeditormodechanged", { + source: this, + mode: this.#annotationEditorMode, + }); + } + }, + { once: true, signal } + ); + // Fetch all the pages since the viewport is needed before printing // starts to create the correct size canvas. Wait until one page is // rendered so we don't tie up too many resources early on. @@ -1090,14 +1104,6 @@ class PDFViewer { ); } - if (this.#annotationEditorUIManager) { - // Ensure that the Editor buttons, in the toolbar, are updated. - eventBus.dispatch("annotationeditormodechanged", { - source: this, - mode: this.#annotationEditorMode, - }); - } - // In addition to 'disableAutoFetch' being set, also attempt to reduce // resource usage when loading *very* long/large documents. if (