diff --git a/src/display/display_utils.js b/src/display/display_utils.js index 2c3fd3f2d..3c44cc9e1 100644 --- a/src/display/display_utils.js +++ b/src/display/display_utils.js @@ -348,21 +348,6 @@ class PDFDateString { } } -/** - * NOTE: This is (mostly) intended to support printing of XFA forms. - */ -function getXfaPageViewport(xfaPage, { scale = 1, rotation = 0 }) { - const { width, height } = xfaPage.attributes.style; - const viewBox = [0, 0, parseInt(width, 10), parseInt(height, 10)]; - - return new PageViewport({ - viewBox, - userUnit: 1, - scale, - rotation, - }); -} - function getRGBA(color) { if (color.startsWith("#")) { // #RRGGBB or #RRGGBBAA @@ -845,7 +830,6 @@ export { getPdfFilenameFromUrl, getRGB, getRGBA, - getXfaPageViewport, isDataScheme, isPdfFile, isValidFetchUrl, diff --git a/src/display/xfa_layer.js b/src/display/xfa_layer.js index 4d055cb42..90f02e30b 100644 --- a/src/display/xfa_layer.js +++ b/src/display/xfa_layer.js @@ -15,10 +15,10 @@ // eslint-disable-next-line max-len /** @typedef {import("./annotation_storage").AnnotationStorage} AnnotationStorage */ -/** @typedef {import("./page_viewport").PageViewport} PageViewport */ // eslint-disable-next-line max-len /** @typedef {import("../../web/pdf_link_service.js").PDFLinkService} PDFLinkService */ +import { PageViewport } from "./page_viewport.js"; import { XfaText } from "./xfa_text.js"; /** @@ -293,6 +293,20 @@ class XfaLayer { parameters.div.style.transform = transform; parameters.div.hidden = false; } + + /** + * NOTE: This is (mostly) intended to support printing of XFA forms. + */ + static getPageViewport(xfaPage, { scale = 1, rotation = 0 }) { + const { width, height } = xfaPage.attributes.style; + + return new PageViewport({ + viewBox: [0, 0, parseInt(width, 10), parseInt(height, 10)], + userUnit: 1, + scale, + rotation, + }); + } } export { XfaLayer }; diff --git a/src/pdf.js b/src/pdf.js index 8e86e7762..e024e8dc8 100644 --- a/src/pdf.js +++ b/src/pdf.js @@ -55,7 +55,6 @@ import { getPdfFilenameFromUrl, getRGB, getRGBA, - getXfaPageViewport, isDataScheme, isPdfFile, noContextMenu, @@ -122,7 +121,6 @@ globalThis.pdfjsLib = { getRGB, getRGBA, getUuid, - getXfaPageViewport, GlobalWorkerOptions, ImageKind, InvalidPDFException, @@ -186,7 +184,6 @@ export { getRGB, getRGBA, getUuid, - getXfaPageViewport, GlobalWorkerOptions, ImageKind, InvalidPDFException, diff --git a/test/unit/pdf_spec.js b/test/unit/pdf_spec.js index 2923c626e..ce40ea159 100644 --- a/test/unit/pdf_spec.js +++ b/test/unit/pdf_spec.js @@ -46,7 +46,6 @@ import { getPdfFilenameFromUrl, getRGB, getRGBA, - getXfaPageViewport, isDataScheme, isPdfFile, noContextMenu, @@ -106,7 +105,6 @@ const expectedAPI = Object.freeze({ getRGB, getRGBA, getUuid, - getXfaPageViewport, GlobalWorkerOptions, ImageKind, InvalidPDFException, diff --git a/web/pdfjs.js b/web/pdfjs.js index dfd7fef36..66bc9f76a 100644 --- a/web/pdfjs.js +++ b/web/pdfjs.js @@ -38,7 +38,6 @@ const { getRGB, getRGBA, getUuid, - getXfaPageViewport, GlobalWorkerOptions, ImageKind, InvalidPDFException, @@ -102,7 +101,6 @@ export { getRGB, getRGBA, getUuid, - getXfaPageViewport, GlobalWorkerOptions, ImageKind, InvalidPDFException, diff --git a/web/print_utils.js b/web/print_utils.js index 04c820de9..e781392a0 100644 --- a/web/print_utils.js +++ b/web/print_utils.js @@ -13,7 +13,7 @@ * limitations under the License. */ -import { getXfaPageViewport, PixelsPerInch } from "pdfjs-lib"; +import { PixelsPerInch, XfaLayer } from "pdfjs-lib"; import { SimpleLinkService } from "./pdf_link_service.js"; import { XfaLayerBuilder } from "./xfa_layer_builder.js"; @@ -51,7 +51,7 @@ function getXfaHtmlForPrinting(printContainer, pdfDocument) { linkService, xfaHtml: xfaPage, }); - const viewport = getXfaPageViewport(xfaPage, { scale }); + const viewport = XfaLayer.getPageViewport(xfaPage, { scale }); builder.render({ viewport, intent: "print" }); page.append(builder.div);