I am using iTextSharp to loop through the fields in the AcroFields
collection so I can set a various properties on an annotation. I have worked out how to pull most of the properties for each of the annotation fields, but would like to be able to cast the individual annotation to the correct field object (i.e., TextField
, PushButtonField
, RadioCheckField
, etc.).
Short of creating a new TextField
, reading and then setting all of the settings/properties associated with it, is there a concise way of getting to:
int index = 0;
AcroFields acroFields = stamper.AcroFields;
TextField tf = acroFields.GetTextField(acroField.Key.ToString(), index);
I am using a very old version of iTextSharp (4.0.6.0). I am unable to upgrade to the latest version as there are breaking changes between 4 and 5.
Additional Information: My PDF files have multiple repeated fields (e.g., two pages have the customer name), so setting a property by using just a key name can have unintended side effects. One field might be left justified while another is centered.