1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 | "use strict";
|
23 |
|
24 | Object.defineProperty(exports, "__esModule", {
|
25 | value: true
|
26 | });
|
27 | exports.XfaLayerBuilder = void 0;
|
28 |
|
29 | var _pdf = require("../pdf");
|
30 |
|
31 | class XfaLayerBuilder {
|
32 | constructor({
|
33 | pageDiv,
|
34 | pdfPage,
|
35 | annotationStorage = null,
|
36 | linkService,
|
37 | xfaHtml = null
|
38 | }) {
|
39 | this.pageDiv = pageDiv;
|
40 | this.pdfPage = pdfPage;
|
41 | this.annotationStorage = annotationStorage;
|
42 | this.linkService = linkService;
|
43 | this.xfaHtml = xfaHtml;
|
44 | this.div = null;
|
45 | this._cancelled = false;
|
46 | }
|
47 |
|
48 | render(viewport, intent = "display") {
|
49 | if (intent === "print") {
|
50 | const parameters = {
|
51 | viewport: viewport.clone({
|
52 | dontFlip: true
|
53 | }),
|
54 | div: this.div,
|
55 | xfaHtml: this.xfaHtml,
|
56 | annotationStorage: this.annotationStorage,
|
57 | linkService: this.linkService,
|
58 | intent
|
59 | };
|
60 | const div = document.createElement("div");
|
61 | this.pageDiv.append(div);
|
62 | parameters.div = div;
|
63 |
|
64 | const result = _pdf.XfaLayer.render(parameters);
|
65 |
|
66 | return Promise.resolve(result);
|
67 | }
|
68 |
|
69 | return this.pdfPage.getXfa().then(xfaHtml => {
|
70 | if (this._cancelled || !xfaHtml) {
|
71 | return {
|
72 | textDivs: []
|
73 | };
|
74 | }
|
75 |
|
76 | const parameters = {
|
77 | viewport: viewport.clone({
|
78 | dontFlip: true
|
79 | }),
|
80 | div: this.div,
|
81 | xfaHtml,
|
82 | annotationStorage: this.annotationStorage,
|
83 | linkService: this.linkService,
|
84 | intent
|
85 | };
|
86 |
|
87 | if (this.div) {
|
88 | return _pdf.XfaLayer.update(parameters);
|
89 | }
|
90 |
|
91 | this.div = document.createElement("div");
|
92 | this.pageDiv.append(this.div);
|
93 | parameters.div = this.div;
|
94 | return _pdf.XfaLayer.render(parameters);
|
95 | }).catch(error => {
|
96 | console.error(error);
|
97 | });
|
98 | }
|
99 |
|
100 | cancel() {
|
101 | this._cancelled = true;
|
102 | }
|
103 |
|
104 | hide() {
|
105 | if (!this.div) {
|
106 | return;
|
107 | }
|
108 |
|
109 | this.div.hidden = true;
|
110 | }
|
111 |
|
112 | }
|
113 |
|
114 | exports.XfaLayerBuilder = XfaLayerBuilder; |
\ | No newline at end of file |