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

Reply via email to