Stephen Friedrich <stephen.friedrich <at> fortis-it.eu> writes:
> > I am generating a PDF using PdfGraphics2D. > > While testing the generated PDF in Adobe > Reader (9.1.0) I noticed that the Reader displays the document just fine, but freezes > on the first mouse click to the document (I was trying to select text): Full > CPU utilization, no redrawing. > > Interestingly Foxit Reader can handle the > document fine. > I suspect that Foxit isn't trying to index text... but I'm wrong. Huh. > > > After a while I found that the reason was > that I forgot to call dispose() on the Graphics2D object I used for drawing. > > So this e-mail is a warning and hopefully a > helpful google-search result for other iText users. > > > > Also, to prevent this kind of mistake: > > Would it be possible to issue a warning (on > the console) if the document is closed while there are still undisposed > Grpahics2D objects for its content? > In a finalize() it would be trivial... but you can never tell when that'll be called. At the moment, PdfContentByte doesn't track any PdfGraphics2D's it may have spawned, so there's no way to check. It could certainly be added... There's a new "sanityCheck()" feature coming in 2.1.6 that checks for mismatched q/Q, BT/ET, etc. It'll catch the mismatched q/Q you end up with when you don't call dispose(). In fact, it caught several in iText's existing unit tests... ;) The exception it throws (yep: it won't let you produce an invalid PDF), will be uncomfortably far removed from the source of the problem (in a newPage(), or doc.close() for example), but such an exception is a good indicator for someone who knows what to look for. Sounds like we could use a little more commentary in the JavaDoc on that one. --Mark Storer ------------------------------------------------------------------------------ This SF.net email is sponsored by: High Quality Requirements in a Collaborative Environment. Download a free trial of Rational Requirements Composer Now! http://p.sf.net/sfu/www-ibm-com _______________________________________________ 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
