Q:
When I call PDFDoc.RefreshFieldAppearances it throws an exception on some PDF files. How do I refresh the appearance of all fields?
----------------------------------------------------------------------
A:
This is caused by malformed (non-conforming) PDF files, which are throwing various errors.
The following code will allow you to traverse all the fields, ignoring any bad ones.
for(FieldIterator itr = pdfdoc.getFieldIterator(); itr.hasNext(); itr.next()) {
try {
Field field = itr.current();
if(field.IsValid()) { field.RefreshAppearance(); }
} catch(Exception e) {
// ignore...
}
}