diff --git a/src/display/api.js b/src/display/api.js index d868304bd..1dfa78b65 100644 --- a/src/display/api.js +++ b/src/display/api.js @@ -783,7 +783,7 @@ class PDFDocumentProxy { * @type {boolean} True if only XFA form. */ get isPureXfa() { - return !!this._transport._htmlForXfa; + return shadow(this, "isPureXfa", !!this._transport._htmlForXfa); } /** @@ -1343,6 +1343,13 @@ class PDFPageProxy { )); } + /** + * @type {boolean} True if only XFA form. + */ + get isPureXfa() { + return shadow(this, "isPureXfa", !!this._transport._htmlForXfa); + } + /** * @returns {Promise} A promise that is resolved with * an {Object} with a fake DOM object (a tree structure where elements diff --git a/web/pdf_page_view.js b/web/pdf_page_view.js index 416ff69fc..b962c3894 100644 --- a/web/pdf_page_view.js +++ b/web/pdf_page_view.js @@ -753,6 +753,7 @@ class PDFPageView { if ( !this.textLayer && this.textLayerMode !== TextLayerMode.DISABLE && + !pdfPage.isPureXfa && this.textLayerFactory ) { this._accessibilityManager ||= new TextAccessibilityManager(); @@ -878,7 +879,7 @@ class PDFPageView { } ); - if (this.xfaLayerFactory) { + if (pdfPage.isPureXfa && this.xfaLayerFactory) { this.xfaLayer ||= this.xfaLayerFactory.createXfaLayerBuilder({ pageDiv: div, pdfPage, diff --git a/web/pdf_viewer.js b/web/pdf_viewer.js index e5b8b9da0..f8686bab3 100644 --- a/web/pdf_viewer.js +++ b/web/pdf_viewer.js @@ -658,7 +658,6 @@ class PDFViewer { if (!pdfDocument) { return; } - const isPureXfa = pdfDocument.isPureXfa; const pagesCount = pdfDocument.numPages; const firstPagePromise = pdfDocument.getPage(1); // Rendering (potentially) depends on this, hence fetching it immediately. @@ -732,13 +731,13 @@ class PDFViewer { if (annotationEditorMode !== AnnotationEditorType.DISABLE) { const mode = annotationEditorMode; - if (isPureXfa) { + if (pdfDocument.isPureXfa) { console.warn("Warning: XFA-editing is not implemented."); } else if (isValidAnnotationEditorMode(mode)) { this.#annotationEditorUIManager = new AnnotationEditorUIManager( this.container, this.eventBus, - this.pdfDocument?.annotationStorage + pdfDocument?.annotationStorage ); if (mode !== AnnotationEditorType.NONE) { this.#annotationEditorUIManager.updateMode(mode); @@ -758,15 +757,6 @@ class PDFViewer { // see issue 15795. docStyle.setProperty("--scale-factor", viewport.scale); - const textLayerFactory = - textLayerMode !== TextLayerMode.DISABLE && !isPureXfa ? this : null; - const annotationLayerFactory = - annotationMode !== AnnotationMode.DISABLE ? this : null; - const xfaLayerFactory = isPureXfa ? this : null; - const annotationEditorLayerFactory = this.#annotationEditorUIManager - ? this - : null; - for (let pageNum = 1; pageNum <= pagesCount; ++pageNum) { const pageView = new PDFPageView({ container: viewerElement, @@ -776,12 +766,16 @@ class PDFViewer { defaultViewport: viewport.clone(), optionalContentConfigPromise, renderingQueue: this.renderingQueue, - textLayerFactory, + textLayerFactory: + textLayerMode !== TextLayerMode.DISABLE ? this : null, textLayerMode, - annotationLayerFactory, + annotationLayerFactory: + annotationMode !== AnnotationMode.DISABLE ? this : null, annotationMode, - xfaLayerFactory, - annotationEditorLayerFactory, + xfaLayerFactory: this, + annotationEditorLayerFactory: this.#annotationEditorUIManager + ? this + : null, textHighlighterFactory: this, structTreeLayerFactory: this, imageResourcesPath: this.imageResourcesPath,