> Is there a way to inspect a file for this defect before 
> attempting the fix? Is it worthwhile to do a test before 
> attempting the fix?

These files will have an entry in their AcroForm dictionary called
"NeedAppearances" set to true.  Furthermore, their fields will not have
appearances ("AP" entries).

boolean checkNeedsApps(PdfReader reader) {
  PdfDictionary root = reader.getCatalog(); // root & catalog are
synonyms as far as PDF is concerned.
  // if root is null, you're Doomed.
  PdfDictionary acroDict = root.getAsDict(PdfName.ACROFORM);

  boolean needsApps = false;
  if (acroDict != null) {
    PdfBoolean appsFlag =
acroDict.getAsBoolean(PdfName.NEEDAPPEARANCES);
    if (appsFlag != null) {
      needsApps = appsFlag.booleanValue();
    }
  }

  return needsApps;  
}


The Bad News:  I just banged the above code out in this email.  The Good
News:  I wrote this very code For Real earlier today to detect when we
were dealing with a form that we built pre-iText... They use the
NeedApparances flag (which causes various sublte and less-than-subtle
issues).  Doh, nigh-identical,but I had a function's case wrong.  Fixed.

I think it'll be fine.

--Mark Storer
  Senior Software Engineer
  Cardiff.com
 
import legalese.Disclaimer;
Disclaimer<Cardiff> DisCard = null;
 

------------------------------------------------------------------------------
This SF.net Dev2Dev email is sponsored by:

Show off your parallel programming skills.
Enter the Intel(R) Threading Challenge 2010.
http://p.sf.net/sfu/intel-thread-sfd
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Buy the iText book: http://www.itextpdf.com/book/
Check the site with examples before you ask questions: 
http://www.1t3xt.info/examples/
You can also search the keywords list: http://1t3xt.info/tutorials/keywords/

Reply via email to