I am trying to add a border around forms in a PDF? How can I accomplish this?
The following code will iterator through every field (or rather each Widget) of a field, and set its border appearance.
Note, you probably want to only do this to certain field types. In general you don’t want to call RefreshAppearance on button widgets.
using (PDFDoc doc = new PDFDoc(output_path + “forms_test1.pdf”))
for(itr=doc.GetFieldIterator(); itr.HasNext(); itr.Next())
Field field = itr.Current();
Widget widget = new Widget(field.GetSDFObj());
widget.SetBorderStyle(new Annot.BorderStyle(Annot.BorderStyle.Style.e_solid, width);
Note, a Widget annotation is the visual representation of a Field. A field can have multiple widgets, for example a single field could be repeated on multiple pages. While each Widget can have a separate appearance (e.g. background color can be different), they would all have the same value (e.g. they all show the same phone number).