@@ -26,9 +26,10 @@ class XfaLayerBuilder {
26
26
/**
27
27
* @param {XfaLayerBuilderOptions } options
28
28
*/
29
- constructor ( { pageDiv, pdfPage, annotationStorage } ) {
29
+ constructor ( { pageDiv, pdfPage, xfaHtml , annotationStorage } ) {
30
30
this . pageDiv = pageDiv ;
31
31
this . pdfPage = pdfPage ;
32
+ this . xfaHtml = xfaHtml ;
32
33
this . annotationStorage = annotationStorage ;
33
34
34
35
this . div = null ;
@@ -42,34 +43,55 @@ class XfaLayerBuilder {
42
43
* annotations is complete.
43
44
*/
44
45
render ( viewport , intent = "display" ) {
45
- return this . pdfPage
46
- . getXfa ( )
47
- . then ( xfa => {
48
- if ( this . _cancelled ) {
49
- return ;
50
- }
51
- const parameters = {
52
- viewport : viewport . clone ( { dontFlip : true } ) ,
53
- div : this . div ,
54
- xfa,
55
- page : this . pdfPage ,
56
- annotationStorage : this . annotationStorage ,
57
- } ;
46
+ if ( intent === "display" ) {
47
+ return this . pdfPage
48
+ . getXfa ( )
49
+ . then ( xfa => {
50
+ if ( this . _cancelled ) {
51
+ return ;
52
+ }
53
+ const parameters = {
54
+ viewport : viewport . clone ( { dontFlip : true } ) ,
55
+ div : this . div ,
56
+ xfa,
57
+ page : this . pdfPage ,
58
+ annotationStorage : this . annotationStorage ,
59
+ } ;
58
60
59
- if ( this . div ) {
60
- XfaLayer . update ( parameters ) ;
61
- } else {
62
- // Create an xfa layer div and render the form
63
- this . div = document . createElement ( "div" ) ;
64
- this . pageDiv . appendChild ( this . div ) ;
65
- parameters . div = this . div ;
61
+ if ( this . div ) {
62
+ XfaLayer . update ( parameters ) ;
63
+ } else {
64
+ // Create an xfa layer div and render the form
65
+ this . div = document . createElement ( "div" ) ;
66
+ this . pageDiv . appendChild ( this . div ) ;
67
+ parameters . div = this . div ;
66
68
67
- XfaLayer . render ( parameters ) ;
68
- }
69
- } )
70
- . catch ( error => {
71
- console . error ( error ) ;
72
- } ) ;
69
+ XfaLayer . render ( parameters ) ;
70
+ }
71
+ } )
72
+ . catch ( error => {
73
+ console . error ( error ) ;
74
+ } ) ;
75
+ }
76
+
77
+ // intent === "print".
78
+ viewport . dontFlip = true ;
79
+ const parameters = {
80
+ viewport,
81
+ div : this . div ,
82
+ xfa : this . xfaHtml ,
83
+ page : null ,
84
+ annotationStorage : this . annotationStorage ,
85
+ } ;
86
+
87
+ // Create an xfa layer div and render the form
88
+ const div = document . createElement ( "div" ) ;
89
+ this . pageDiv . appendChild ( div ) ;
90
+ parameters . div = div ;
91
+
92
+ XfaLayer . render ( parameters ) ;
93
+
94
+ return null ;
73
95
}
74
96
75
97
cancel ( ) {
@@ -92,12 +114,19 @@ class DefaultXfaLayerFactory {
92
114
* @param {HTMLDivElement } pageDiv
93
115
* @param {PDFPage } pdfPage
94
116
* @param {AnnotationStorage } [annotationStorage]
117
+ * @param {Object } [xfaHtml]
95
118
*/
96
- createXfaLayerBuilder ( pageDiv , pdfPage , annotationStorage = null ) {
119
+ createXfaLayerBuilder (
120
+ pageDiv ,
121
+ pdfPage ,
122
+ annotationStorage = null ,
123
+ xfaHtml = null
124
+ ) {
97
125
return new XfaLayerBuilder ( {
98
126
pageDiv,
99
127
pdfPage,
100
128
annotationStorage,
129
+ xfaHtml,
101
130
} ) ;
102
131
}
103
132
}
0 commit comments