diff --git a/web/base_viewer.js b/web/base_viewer.js index ede70ee5f..e4dce389c 100644 --- a/web/base_viewer.js +++ b/web/base_viewer.js @@ -435,6 +435,8 @@ class BaseViewer { const pagesCount = pdfDocument.numPages; const firstPagePromise = pdfDocument.getPage(1); + const annotationStorage = pdfDocument.annotationStorage; + this._pagesCapability.promise.then(() => { this.eventBus.dispatch("pagesloaded", { source: this, @@ -481,6 +483,7 @@ class BaseViewer { eventBus: this.eventBus, id: pageNum, scale, + annotationStorage, defaultViewport: viewport.clone(), renderingQueue: this.renderingQueue, textLayerFactory, @@ -1153,6 +1156,7 @@ class BaseViewer { createAnnotationLayerBuilder( pageDiv, pdfPage, + annotationStorage = null, imageResourcesPath = "", renderInteractiveForms = false, l10n = NullL10n @@ -1160,11 +1164,11 @@ class BaseViewer { return new AnnotationLayerBuilder({ pageDiv, pdfPage, + annotationStorage, imageResourcesPath, renderInteractiveForms, linkService: this.linkService, downloadManager: this.downloadManager, - annotationStorage: this.pdfDocument.annotationStorage, l10n, }); } diff --git a/web/interfaces.js b/web/interfaces.js index 7db2de726..81dd4b2e0 100644 --- a/web/interfaces.js +++ b/web/interfaces.js @@ -165,7 +165,8 @@ class IPDFAnnotationLayerFactory { /** * @param {HTMLDivElement} pageDiv * @param {PDFPage} pdfPage - * @param {AnnotationStorage} [annotationStorage] + * @param {AnnotationStorage} [annotationStorage] - Storage for annotation + * data in forms. * @param {string} [imageResourcesPath] - Path for image resources, mainly * for annotation icons. Include trailing slash. * @param {boolean} renderInteractiveForms diff --git a/web/pdf_page_view.js b/web/pdf_page_view.js index ecf0326f8..966f5b6ac 100644 --- a/web/pdf_page_view.js +++ b/web/pdf_page_view.js @@ -38,6 +38,8 @@ import { viewerCompatibilityParams } from "./viewer_compatibility.js"; * @property {number} id - The page unique ID (normally its number). * @property {number} scale - The page scale display. * @property {PageViewport} defaultViewport - The page viewport. + * @property {AnnotationStorage} [annotationStorage] - Storage for annotation + * data in forms. The default value is `null`. * @property {PDFRenderingQueue} renderingQueue - The rendering queue object. * @property {IPDFTextLayerFactory} textLayerFactory * @property {number} [textLayerMode] - Controls if the text layer used for @@ -81,6 +83,7 @@ class PDFPageView { this.rotation = 0; this.scale = options.scale || DEFAULT_SCALE; this.viewport = defaultViewport; + this._annotationStorage = options.annotationStorage || null; this.pdfPageRotate = defaultViewport.rotation; this.hasRestrictedScaling = false; this.textLayerMode = Number.isInteger(options.textLayerMode) @@ -533,6 +536,7 @@ class PDFPageView { this.annotationLayer = this.annotationLayerFactory.createAnnotationLayerBuilder( div, pdfPage, + this._annotationStorage, this.imageResourcesPath, this.renderInteractiveForms, this.l10n