@@ -171,10 +171,19 @@ var calculateAppearanceStream = function(formObject) {
171171 return formObject . appearanceStreamContent ;
172172 }
173173
174+ // fixme test what happens with AcroFormTextFieldParent if no value is set
174175 if ( ! formObject . V && ! formObject . DV ) {
175176 return ;
176177 }
177178
179+ // I don't think I need to do this. I need to find where conditionals are used on _V and skip those if instanceof AcroFormTextFieldParent
180+ if ( formObject instanceof AcroFormTextFieldParent ) {
181+ var appearanceStreamContent = createFormXObject ( formObject ) ;
182+ appearanceStreamContent . scope = formObject . scope ;
183+ // appearanceStreamContent.stream = stream.join("\n");
184+ return appearanceStreamContent ;
185+ }
186+
178187 // else calculate it
179188
180189 var stream = [ ] ;
@@ -588,6 +597,7 @@ var createFieldCallback = function(fieldArray, scope) {
588597 ) {
589598 // Calculate Appearance
590599 var appearance = calculateAppearanceStream ( fieldObject ) ;
600+ // fixme maybe probably don't want this to happen for acroformtextparents
591601 keyValueList . push ( { key : "AP" , value : "<</N " + appearance + ">>" } ) ;
592602
593603 scope . internal . acroformPlugin . xForms . push ( appearance ) ;
@@ -1192,7 +1202,9 @@ var AcroFormField = function() {
11921202 get : function ( ) {
11931203 if ( ! _T || _T . length < 1 ) {
11941204 // In case of a Child from a Radio´Group, you don't need a FieldName
1195- if ( this instanceof AcroFormChildClass ) {
1205+ if ( this instanceof AcroFormChildClass ||
1206+ this instanceof AcroFormTextFieldChild
1207+ ) {
11961208 return undefined ;
11971209 }
11981210 _T = "FieldObject" + AcroFormField . FieldNum ++ ;
@@ -1336,7 +1348,9 @@ var AcroFormField = function() {
13361348 if (
13371349 ! _DA ||
13381350 this instanceof AcroFormChildClass ||
1339- this instanceof AcroFormTextField
1351+ this instanceof AcroFormTextField &&
1352+ ! ( this instanceof AcroFormTextFieldParent )
1353+ // fixme does the textfieldparent actually need a default appearance?
13401354 ) {
13411355 return undefined ;
13421356 }
@@ -1696,7 +1710,7 @@ var AcroFormField = function() {
16961710 if ( ! Object . keys ( _MK ) . length ) {
16971711 return undefined ;
16981712 }
1699-
1713+
17001714 var result = [ ] ;
17011715 result . push ( "<<" ) ;
17021716 for ( let key in _MK ) {
@@ -2619,6 +2633,60 @@ var AcroFormTextField = function() {
26192633} ;
26202634inherit ( AcroFormTextField , AcroFormField ) ;
26212635
2636+ var AcroFormTextFieldParent = function ( ) {
2637+ AcroFormTextField . call ( this ) ;
2638+ // fixme try this. see if any other properties need to be nullified
2639+ // this.F = null;
2640+ // this.MK = null;
2641+ // this.Type = null;
2642+ // this.Subtype = null;
2643+
2644+ var _Kids = [ ] ;
2645+ Object . defineProperty ( this , "Kids" , {
2646+ enumerable : true ,
2647+ configurable : false ,
2648+ get : function ( ) {
2649+ return _Kids ;
2650+ } ,
2651+ set : function ( value ) {
2652+ if ( typeof value !== "undefined" ) {
2653+ _Kids = value ;
2654+ } else {
2655+ _Kids = [ ] ;
2656+ }
2657+ }
2658+ } ) ;
2659+ }
2660+ inherit ( AcroFormTextFieldParent , AcroFormTextField ) ;
2661+
2662+ var AcroFormTextFieldChild = function ( ) {
2663+ AcroFormTextField . call ( this ) ;
2664+
2665+ var _parent ;
2666+ Object . defineProperty ( this , "Parent" , {
2667+ enumerable : false ,
2668+ configurable : false ,
2669+ get : function ( ) {
2670+ return _parent ;
2671+ } ,
2672+ set : function ( value ) {
2673+ _parent = value ;
2674+ }
2675+ } ) ;
2676+
2677+ } ;
2678+ inherit ( AcroFormTextFieldChild , AcroFormTextField ) ;
2679+
2680+ AcroFormTextFieldParent . prototype . createChild = function ( ) {
2681+ var child = new AcroFormTextFieldChild ( ) ;
2682+ child . Parent = this ;
2683+ this . Kids . push ( child ) ;
2684+ addField . call ( this . scope , child ) ;
2685+
2686+ return child ;
2687+ }
2688+
2689+
26222690/**
26232691 * @class AcroFormPasswordField
26242692 * @extends AcroFormTextField
@@ -3757,15 +3825,18 @@ AcroFormAppearance.internal = {
37573825
37583826AcroFormAppearance . internal . getWidth = function ( formObject ) {
37593827 var result = 0 ;
3760- if ( typeof formObject === "object" ) {
3828+ // fixme might not need && formObject.Rect if textfieldparent doesn't need an xform object
3829+ if ( typeof formObject === "object" && formObject . Rect ) {
37613830 result = scale ( formObject . Rect [ 2 ] ) ;
37623831 }
37633832 return result ;
37643833} ;
37653834
37663835AcroFormAppearance . internal . getHeight = function ( formObject ) {
37673836 var result = 0 ;
3768- if ( typeof formObject === "object" ) {
3837+ // fixme might not need && formObject.Rect if textfieldparent doesn't need an xform object
3838+
3839+ if ( typeof formObject === "object" && formObject . Rect ) {
37693840 result = scale ( formObject . Rect [ 3 ] ) ;
37703841 }
37713842 return result ;
@@ -3805,6 +3876,7 @@ jsPDFAPI.AcroFormCheckBox = AcroFormCheckBox;
38053876jsPDFAPI . AcroFormTextField = AcroFormTextField ;
38063877jsPDFAPI . AcroFormPasswordField = AcroFormPasswordField ;
38073878jsPDFAPI . AcroFormAppearance = AcroFormAppearance ;
3879+ jsPDFAPI . AcroFormTextFieldParent = AcroFormTextFieldParent ;
38083880
38093881jsPDFAPI . AcroForm = {
38103882 ChoiceField : AcroFormChoiceField ,
@@ -3816,6 +3888,7 @@ jsPDFAPI.AcroForm = {
38163888 RadioButton : AcroFormRadioButton ,
38173889 CheckBox : AcroFormCheckBox ,
38183890 TextField : AcroFormTextField ,
3891+ TextFieldParent : AcroFormTextFieldParent ,
38193892 PasswordField : AcroFormPasswordField ,
38203893 Appearance : AcroFormAppearance
38213894} ;
@@ -3830,6 +3903,7 @@ jsPDF.AcroForm = {
38303903 RadioButton : AcroFormRadioButton ,
38313904 CheckBox : AcroFormCheckBox ,
38323905 TextField : AcroFormTextField ,
3906+ TextFieldParent : AcroFormTextFieldParent ,
38333907 PasswordField : AcroFormPasswordField ,
38343908 Appearance : AcroFormAppearance
38353909} ;
@@ -3847,6 +3921,7 @@ export {
38473921 AcroFormRadioButton ,
38483922 AcroFormCheckBox ,
38493923 AcroFormTextField ,
3924+ AcroFormTextFieldParent ,
38503925 AcroFormPasswordField ,
38513926 AcroFormAppearance
38523927} ;
0 commit comments