Hello,
when trying to update jPDF Tweak to use the latest released iText version (2.1.5), I noticed that current iText is quite bad to hyperlinks. I did some bisection search today and found that the problem appeared in SVN revision 3721: http://itext.svn.sf.net/viewvc/itext?view=rev&revision=3721 (that's why I put mstorer into Cc). The symptom is that whenever you try to read the hyperlinks from a PDF document created by LaTeX + dvips + ps2pdf which contains hyperlinks, you get the following exception (this stacktrace is from revision 3721): > java.lang.IllegalArgumentException: You have to consolidate the named > destinations of your reader. > at > com.lowagie.text.pdf.PdfAnnotation$PdfImportedLink.<init>(PdfAnnotation.java:818) > at com.lowagie.text.pdf.PdfReader.getLinks(PdfReader.java:2656) This only happens if the PDF is partial. To reproduce, just run the following code on the attached PDF. String filename = "D:\\temp\\buggy.pdf"; PdfReader rdr = new PdfReader(new RandomAccessFileOrArray(filename), new byte[0]); // this one works: PdfReader rdr = new PdfReader(filename); rdr.consolidateNamedDestinations(); // does not help rdr.getLinks(1); Yes, I know, that getLinks method has initially been implemented by me (so shame on me) but it seems the PDFReader got that much more complexity since then that I cannot really understand what is going on here, especially since the non-partial constructor of PdfReader works. Should I just use the non-partial version (with the filename instead of the RandomAccessFileOrArray)? Or stay with iText 2.1.4? Thanks in advance, Michael PS: I have yet another bug report about hyperlinks, that seems to have been there forever (at least since iText 2.1.0), but it only happens on one specific PDF file (involving a NullPointerException at PdfWriter.getNewObjectNumber). Is anyone willing to dig into it or should I just ignore it since it is not reproducable with any different files?
buggy.pdf
Description: Adobe PDF document
------------------------------------------------------------------------------ Stay on top of everything new and different, both inside and around Java (TM) technology - register by April 22, and save $200 on the JavaOne (SM) conference, June 2-5, 2009, San Francisco. 300 plus technical and hands-on sessions. Register today. Use priority code J9JMT32. http://p.sf.net/sfu/p
_______________________________________________ iText-questions mailing list iText-questions@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/itext-questions Buy the iText book: http://www.1t3xt.com/docs/book.php