iTextSharp acroFields.SetField method and multiple

2019-06-11 04:49发布

问题:

In case of multiple fields with same name iTextSharp acroFields.SetField(Name, Value) sets value for first field only. How to set the value for the rest of the fields? When looping thru the acroFields.Fields the field names are reported as

form1[0].#subform[0].TextField1[0] - TextField
form1[0].#subform[0].TextField2[0] - TextField
form1[0].#subform[0].TextField2[1] - TextField
form1[0].#subform[0].TextField2[2] - TextField

When using

acroFields.SetField("TextField1", Value);

the value of text field named as TextField1 is set. there is only one field named as TextField1 so it is fine. However when using

acroFields.SetField("TextField2", Value);

the value of first text field named as TextField2 is set. The rest two fields named as TextField2 are left unset.

The PDF is created with Adobe LiveCycle and saved as Static PDF i.e. it is not Dynamic XFA.

回答1:

Can you just use the full field name?

acroFields.SetField("form1[0].#subform[0].TextField2[0]", Value);