Java Mailing List Archive

http://www.junlu.com/

Google
Google
Mailing List
Home
Forum Home
JBoss - Java Application Server
Tomcat - JSP/Servlet container
Struts - A MVC web framework
iText - An open source PDF Java Library
JDOM - JDOM XML Parser
J2EE - A mailing list for Java(tm) 2 Platform, Enterprise Edition
J2EE Pattern - An interest list for Sun Java Center J2EE Pattern Catalog
JSP - A mailing list about Java Server Pages specification and reference
Servlet - A mailing list for discussion about Sun Microsystem's Java Servlet API Technology
Struts & Hibernate
Subjects
JSP editor plugin for eclipse ?
org apache jasper JasperException: Unable to compile class for JSP
Tomcat: Connection reset by peer: socket write error
Cannot retrieve definition for form bean null
Struts Tiles Tutorial (free Struts training)
Where do I download Tomcat 4 0 6?
Data Access Object (DAO) pattern, example DAO 's
Where to download Tomcat v 4 1 24 from?
Tomcat 5 0 16 Requested resource not available
Oracle Connection Pooling in 3 2 2
Servlet : Session invalidate
Servlet action is currently unavailable
Tomcat/Struts Unicode Encoding/Decoding problems
Tomcat and webapplication specific java library path
Running a Simple JMS Example
Mapping in workers2 properties
org apache jasper JasperException
Cannot find message resources under key org apache struts action
   MESSAGE
problem with html:text bean throwing exception
Cannot find message resources under key org apache struts action MESSAGE
invalid direct reference problem with solution
Tool for jsp debug Try Sysdeo Eclipse Plugin
Tomcat 5 Cannot load JDBC driver class 'null ' SQL state: null
weblogic ejbc
java properties file
Jboss 3 2 3 Coyote Can 't re
Tomcat 5, Apache2 and mod jk2 integration problem
JBoss example problem new to J2EE
url string for connecting jboss to oracle
Value attribute of <html:checkbox
javax servlet ServletException: BeanUtils populate
HTTP Status 404 The requested resource is not available
5 0 18: Windows XP Pro vs Windows 2000
 
ClassCastException with getAcroFields

ClassCastException with getAcroFields

2006-09-05       - By Mark Storer

 Back
Reply:     1     2  

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: itext-questions-bounces@(protected)
> [mailto:itext-questions-bounces@(protected)]On Behalf Of
> Bertrand Beyssac
> Sent: Tuesday, September 05, 2006 8:16 AM
> To: itext-questions@(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 Source code of java.lang.ClassCastException
>   at com.lowagie.text.pdf.XfaForm.<init>(Unknown Source)
>   at com.lowagie.text.pdf.AcroFields Source code of com.lowagie.text.pdf.AcroFields<init>(Unknown Source)
>   at com.lowagie.text.pdf.PdfReader Source code of com.lowagie.text.pdf.PdfReader(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
iText-questions@(protected)
https://lists.sourceforge.net/lists/listinfo/itext-questions

©2008 junlu.com - Jax Systems, LLC, U.S.A.