mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-08 01:10:08 +02:00
Move the Default{...}LayerFactory
into a new web/default_factory.js
file
This patch, first of all, removes circular dependencies in the TypeScript definitions. Secondly, it also moves `RenderingStates` into `web/ui_utils.js` to break another type-dependency and directly use the `XfaLayerBuilder` during XFA-printing. Finally, note that this patch *slightly* reduces the size of the default viewer (e.g. in the `MOZCENTRAL` build) by not having to bundle code which is completely unused.
This commit is contained in:
parent
e0dba504d2
commit
e19020c028
21 changed files with 221 additions and 186 deletions
|
@ -14,11 +14,12 @@
|
|||
*/
|
||||
|
||||
import { getXfaPageViewport, PixelsPerInch } from "pdfjs-lib";
|
||||
import { DefaultXfaLayerFactory } from "./xfa_layer_builder.js";
|
||||
import { SimpleLinkService } from "./pdf_link_service.js";
|
||||
import { XfaLayerBuilder } from "./xfa_layer_builder.js";
|
||||
|
||||
function getXfaHtmlForPrinting(printContainer, pdfDocument) {
|
||||
const xfaHtml = pdfDocument.allXfaHtml;
|
||||
const factory = new DefaultXfaLayerFactory();
|
||||
const linkService = new SimpleLinkService();
|
||||
const scale = Math.round(PixelsPerInch.PDF_TO_CSS_UNITS * 100) / 100;
|
||||
|
||||
for (const xfaPage of xfaHtml.children) {
|
||||
|
@ -26,12 +27,13 @@ function getXfaHtmlForPrinting(printContainer, pdfDocument) {
|
|||
page.className = "xfaPrintedPage";
|
||||
printContainer.appendChild(page);
|
||||
|
||||
const builder = factory.createXfaLayerBuilder(
|
||||
/* pageDiv = */ page,
|
||||
/* pdfPage = */ null,
|
||||
/* annotationStorage = */ pdfDocument.annotationStorage,
|
||||
/* xfaHtml = */ xfaPage
|
||||
);
|
||||
const builder = new XfaLayerBuilder({
|
||||
pageDiv: page,
|
||||
pdfPage: null,
|
||||
annotationStorage: pdfDocument.annotationStorage,
|
||||
linkService,
|
||||
xfaHtml: xfaPage,
|
||||
});
|
||||
const viewport = getXfaPageViewport(xfaPage, { scale });
|
||||
|
||||
builder.render(viewport, "print");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue