Thanks! ;)

Seriously, though, I think lastXrefPartial should eventually be removed from 
the PdfReader --- as soon as someone has enough time to spare, that is ;*).

lastXrefPartial seems to have been introduced into the code to be able to keep 
Java objects representing indirect PDF objects in the xrefObj list only for a 
short time (short enough to prevent memory exhaustion, long enough to prevent 
multiple reads of the same indirect PDF objects in short order)... A kind of a 
one element cache at a variable position in that list...

At the same time you can keep the object in memory for a longer time if you 
intentionally "forget" to releaseLastXrefPartial() (or more cleanly explicitly 
call resetLastXrefPartial()); this is one way to make objects that either were 
manipulated or are likely to be used all the time remain in the xrefObj list.

Unfortunately if reading and releasing of separate such objects overlap, this 
doesn't work properly anymore --- the first object read may remain in the list 
without need while the second one may be removed (by a release call intended 
for the first) even though it was manipulated and, therefore, needed to remain 
in memory. This requires work-arounds as seen in consolidateNamedDestinations() 
and replaceNamedDestination() which are quite fragile as this thread shows.

Regards,   Michael.

-----Original Message-----
From: 1T3XT info [mailto:[email protected]] 
Sent: Thursday, April 16, 2009 6:22 PM
To: Post all your questions about iText here
Subject: Re: [iText-questions] Hyperlink Regression in iText 2.1.6 (SVN 
revision 3721 by mstorer)

Michael Schierl wrote:
> 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);

I applied a hack (see SVN) based on the analysis of the other Michael
(the one from wir-sind-cool; who really is cool ;-) ).
As Michael points out, it's not very elegant to depend on a side effect,
and that's why I talk about a hack when referring to the change I made,
but I tested your example and it seems to work now.
-- 
This answer is provided by 1T3XT BVBA
http://www.1t3xt.com/ - http://www.1t3xt.info
-- 
Psssst! Schon vom neuen GMX MultiMessenger gehört? Der kann`s mit allen: 
http://www.gmx.net/de/go/multimessenger01

------------------------------------------------------------------------------
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Buy the iText book: http://www.1t3xt.com/docs/book.php

Reply via email to