Hi Arashi,
Thanks for your patience.
The product team has further investigated the issue PDFNEWNET-39170 reported earlier and as per our observations, your document contains static XFA form. That’s why its fields may be accessed both via Document.Form (as for standard form), and via XFA. Therefore you need to take into consideration that form has hierarchical structure and that’s why it requires recursive scan of the field. If field contains subfields they should be iterated.
Sample code:[C#]
private void ScanFields(string rootName, Field
field)<o:p></o:p>
{
foreach (Field
subField in field)
{
//if this field does not contain subfield, it is
"terminal" field and we should get its type and value.
//RadioButton field is "special case", it
contains subfiels (we can access to every radio button option as different
field) but we should query value from RadioButton field in order to check which
exactpy option is checked.
if (subField.Count == 0 || subField is RadioButtonField))
{
Console.WriteLine(rootName + "." + subField.PartialName + " type = " + subField.GetType() + " value = " + subField.Value);
}
//else we call this method recursively for each subfield.
else
{
ScanFields(rootName + "." +
subField.PartialName, subField);
}
}
}
public void ShowFields()
{
Document doc = new
Document("RadioButtons.pdf");
foreach (Field
field in doc.Form)
{
ScanFields("", field);
}
}
From other hand, you may access to fields via XFA. In order to determine field type customer should check field template which may be get with GetFieldTempate method.
Field template is XML which have the following form <$fieldtype>… </$fieldtype> where $fieldtype is one of field types, for example textEdit, checkBox etc.
For example …
[C#]
Document doc = new
Document(“RadioButtons.pdf”);<o:p></o:p>
foreach (string field in doc.Form.XFA.FieldNames)
{
XmlNode tmpl =
doc.Form.XFA.GetFieldTemplate(field);
Console.WriteLine(field + "
type = " + tmpl.ChildNodes[0].ChildNodes[0].Name + " value = " + doc.Form.XFA[field]);
}