Hello,
I'm evaluating iText for use as a possible front-end parser to parse and
analyze the structure and content of PDF documents. (So, I'm not using the PDF
generation/rendering capabilities of iText).
In general I've found that iText PdfReader does an excellent job of parsing PDF
objects out of documents. But recently I encountered a java.lang exception
while using the iText5 API (PdfReader.getJavaScript()) to parse a document with
embedded JavaScript, which seemed unusual:
Exception in thread "main" java.lang.ClassCastException:
com.itextpdf.text.pdf.PdfString cannot be cast to
com.itextpdf.text.pdf.PdfDictionary
at com.itextpdf.text.pdf.PdfReader.getJavaScript(PdfReader.java:3201)
It turned out that the document was corrupted, such that there was a PdfString
in the name list, instead of a PdfDictionary as required by the ISO 32000
specification. Adobe Reader can open and display this document, but some of the
bookmarks don't work, which might be associated with this mal-formed object
[which was created by iTextSharp BTW].
I hesitate to call this a bug in the API code, because the exception can be
caught with additional code in the user application. And iText is certainly not
responsible for documents that are not well-formed. But I am just pointing out
that perhaps there should be some kind of general guard or mechanism to handle
these kinds of malformed objects, that are not written in accordance with
formal specifications.
What are your views on the proper handling of these kinds of errors?
Thanks,
John Day
R&D Systems Engineer
Northrop Grumman Corporation
------------------------------------------------------------------------------
LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial
Remotely access PCs and mobile devices and provide instant support
Improve your efficiency, and focus on delivering more value-add services
Discover what IT Professionals Know. Rescue delivers
http://p.sf.net/sfu/logmein_12329d2d
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions
iText(R) is a registered trademark of 1T3XT BVBA.
Many questions posted to this list can (and will) be answered with a reference
to the iText book: http://www.itextpdf.com/book/
Please check the keywords list before you ask for examples:
http://itextpdf.com/themes/keywords.php