protected void IterateFields(PdfArray fieldlist, PRIndirectReference fieldDict, String parentPath)
{
foreach (PRIndirectReference refi in fieldlist.ArrayList) {
PdfDictionary dict = (PdfDictionary) PdfReader.GetPdfObjectRelease(refi);
// if we are not a field dictionary, pass our parent's values
PRIndirectReference myFieldDict = fieldDict;
String fullPath = parentPath;
PdfString tField = (PdfString)dict.Get(PdfName.T);
bool isFieldDict = tField != null;
if (isFieldDict) {
myFieldDict = refi;
if (parentPath == null) {
fullPath = tField.ToString();
} else {
fullPath = parentPath + '.' + tField.ToString();
}
}
PdfArray kids = (PdfArray)dict.Get(PdfName.KIDS);
if (kids != null) {
PushAttrib(dict);
IterateFields(kids, myFieldDict, fullPath);
stack.RemoveAt(stack.Count - 1); // pop
}
else { // leaf node
if (myFieldDict != null) {
PdfDictionary mergedDict = (PdfDictionary)stack[stack.Count - 1];
if (isFieldDict)
mergedDict = MergeAttrib(mergedDict, dict);
mergedDict.Put(PdfName.T, new PdfString(fullPath));
FieldInformation fi = new FieldInformation(fullPath, mergedDict, myFieldDict);
fields.Add(fi);
fieldByName[fullPath] = fi;
}
}
}
}