I think it's time to eliminate PdfNull at least inside PdfReader. PdfNull has no reason to exist in PdfDictionary and it's easy for PdfArray to output a null if it finds a null. If something breaks because of this we are here to fix it. I notice that in the last few years everybody produces PDFs but unfortunately they are either broken (if Acrobat opens it it isn't broken) or the structure is on the verge of incompatibility (if the pdf reference doesn't disallow it I can do everything).
Paulo ----- Original Message ----- From: "Mark Storer" <[EMAIL PROTECTED]> To: "Post all your questions about iText here" <[email protected]> Sent: Tuesday, September 05, 2006 6:25 PM Subject: Re: [iText-questions] ClassCastException with getAcroFields > Executive Summary: It's a bad PDF. > > > It has an "AcroForm" entry in the root object ('catalog'), but it points > to a missing object. IIRC, iText will substitute a PdfNull in place of > any absentee objects in the cross reference table (a list of all the > objects in the file with their byte offsets). And while there is a slot > for the AcroForm object in the list, it's pointing off to lala-land. > > According to my theory, the XfaForm constructor tries to treat the > AcroForm object like a dictionary (as it should be), you get that > exception because it's a PdfNull instead. > > The info dictionary states that this PDF was produced by MS Word using > Distiller... which is supriseing, because I wouldn't expect distiller to > produce a 'broken' PDF like this. There aren't any annotations of any > kind in the PDF itself, so it's possible that Word thought there might be > form fields, and did some setup, but never cleaned up after itself when it > turned out that there weren't any. > > When Acrobat opens the document it strips out the AcroForm entry from the > root object, sanitizing the PDF. It opens fine in Acrobat (and I would > presume in Reader). > > iText will normally strip entries out of a dictionary if they're set to > PdfNull, but because the "AcroForm" entry reffers to another object in the > cross-reference table, it sees the reference, not PdfNull. > > And just to make matters worse, the missing entries in the cross reference > table aren't properly noted as such, further confusing iText. > > --Mark Storer > Senior Software Engineer > Cardiff Software > > #include <disclaimer> > typedef std::Disclaimer<Cardiff> DisCard; > > > >> -----Original Message----- >> From: [EMAIL PROTECTED] >> [mailto:[EMAIL PROTECTED] Behalf Of >> Bertrand Beyssac >> Sent: Tuesday, September 05, 2006 8:16 AM >> To: [email protected] >> Subject: [iText-questions] ClassCastException with getAcroFields >> >> >> >> I have a ClassCastException using following lines with >> attached file on >> "getAcroFields" method. >> >> I use iText 1.4.4. >> >> >> PdfReader pdfReader = new PdfReader("bug.pdf"); >> PdfStamper pdfStamper = new PdfStamper(pdfReader, new >> FileOutputStream("final.pdf")); >> >> AcroFields acroFields = pdfStamper.getAcroFields(); >> >> java.lang.ClassCastException >> at com.lowagie.text.pdf.XfaForm.<init>(Unknown Source) >> at com.lowagie.text.pdf.AcroFields.<init>(Unknown Source) >> at com.lowagie.text.pdf.PdfReader.getAcroFields(Unknown Source) >> >> >> Bertrand >> > > ------------------------------------------------------------------------- > Using Tomcat but need to do more? Need to support web services, security? > Get stuff done quickly with pre-integrated technology to make your job > easier > Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 > _______________________________________________ > iText-questions mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/itext-questions ------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 _______________________________________________ iText-questions mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/itext-questions
