diff --git a/src/display/api.js b/src/display/api.js index f4589953c..5def0a75b 100644 --- a/src/display/api.js +++ b/src/display/api.js @@ -1381,6 +1381,13 @@ class PDFPageProxy { return this._transport.getPageJSActions(this._pageIndex); } + /** + * @type {Object} The filter factory instance. + */ + get filterFactory() { + return this._transport.filterFactory; + } + /** * @type {boolean} True if only XFA form. */ diff --git a/web/pdf_page_view.js b/web/pdf_page_view.js index b31408767..5626956fe 100644 --- a/web/pdf_page_view.js +++ b/web/pdf_page_view.js @@ -13,8 +13,6 @@ * limitations under the License. */ -// eslint-disable-next-line max-len -/** @typedef {import("../src/display/base_factory.js").BaseFilterFactory} BaseFilterFactory */ // eslint-disable-next-line max-len /** @typedef {import("../src/display/display_utils").PageViewport} PageViewport */ // eslint-disable-next-line max-len @@ -86,8 +84,6 @@ import { XfaLayerBuilder } from "./xfa_layer_builder.js"; * @property {IL10n} [l10n] - Localization service. * @property {function} [layerProperties] - The function that is used to lookup * the necessary layer-properties. - * @property {BaseFilterFactory} [filterFactory] - Factory to create some SVG - * filters. */ const MAX_CANVAS_PIXELS = compatibilityParams.maxCanvasPixels || 16777216; @@ -174,6 +170,7 @@ class PDFPageView { this.resume = null; if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) { this._isStandalone = !this.renderingQueue?.hasViewer(); + this._container = container; } this._annotationCanvasMap = null; @@ -207,21 +204,6 @@ class PDFPageView { "--scale-factor", this.scale * PixelsPerInch.PDF_TO_CSS_UNITS ); - if ( - options.filterFactory && - (this.pageColors?.foreground === "CanvasText" || - this.pageColors?.background === "Canvas") - ) { - container?.style.setProperty( - "--hcm-highligh-filter", - options.filterFactory.addHighlightHCMFilter( - "CanvasText", - "Canvas", - "HighlightText", - "Highlight" - ) - ); - } const { optionalContentConfigPromise } = options; if (optionalContentConfigPromise) { @@ -295,6 +277,22 @@ class PDFPageView { } setPdfPage(pdfPage) { + if ( + (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) && + this._isStandalone && + (this.pageColors?.foreground === "CanvasText" || + this.pageColors?.background === "Canvas") + ) { + this._container?.style.setProperty( + "--hcm-highligh-filter", + pdfPage.filterFactory.addHighlightHCMFilter( + "CanvasText", + "Canvas", + "HighlightText", + "Highlight" + ) + ); + } this.pdfPage = pdfPage; this.pdfPageRotate = pdfPage.rotate; @@ -585,10 +583,7 @@ class PDFPageView { (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) && this._isStandalone ) { - this.div.parentNode?.style.setProperty( - "--scale-factor", - this.viewport.scale - ); + this._container?.style.setProperty("--scale-factor", this.viewport.scale); } let isScalingRestricted = false; diff --git a/web/pdf_viewer.js b/web/pdf_viewer.js index 363000fd8..b208d79c6 100644 --- a/web/pdf_viewer.js +++ b/web/pdf_viewer.js @@ -916,7 +916,6 @@ class PDFViewer { pageColors: this.pageColors, l10n: this.l10n, layerProperties, - filterFactory: pdfDocument.filterFactory, }); this._pages.push(pageView); }