iTextSharp acroFields.SetField method and multiple form fields with same name

落爺英雄遲暮 提交于 2019-12-23 04:43:09

问题


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);


来源:https://stackoverflow.com/questions/6714255/itextsharp-acrofields-setfield-method-and-multiple-form-fields-with-same-name

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!