Michael Schierl <schierlm <at> gmx.de> writes:
> 
> > 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?
> 

That or share the code to PdfReader.getLinks() so we can find your bugs.  ;)  I,
being infallible, am clearly not to blame.

The act of keeping references to the 'direct' objects from their references like
this was a pretty fundamental change in the way iText works... I compared it to
changing the speed of light by a tiny amount on the dev list.  That's what the
"C *= 1.02" thing alludes to in the check-in comment.

Buggy.pdf has 3 named destinations, all of which use the same indirect object, :
Doc-Start [ 4 0 R ]
page.1 [ 4 0 R ]
section.1 [ 4 0 R ]

It's entirely possible that there's a bug in consolidateNamedDestinations()...
induced by my check-in.  Lets have a look... nothing glaring at me.  Not much of
a 'consolidation' really, but okay.  It stuffs the dest array in to replace any
name or string destination.  

Okay, how about the line that's actually throwing:

        PdfImportedLink(PdfDictionary annotation) {
                parameters.putAll(annotation.hashMap);
                try {
                        destination = (PdfArray) 
parameters.remove(PdfName.DEST);
                } catch (ClassCastException ex) {
                        throw new IllegalArgumentException("You have to 
consolidate the named
destinations of your reader.");
                }


That looks an awful lot like it should work.  Clearly, something is... amiss. 
Only I'm infallible, so it must be your fault, trying to discredit me out of
jealous at how awesome I am.

Or I could have broken something.  :\

Can we get a look at your getLink code?

--Mark Storer



------------------------------------------------------------------------------
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

Reply via email to