Sure, see attachment.
Here's the iText example code I used to generate that file:

    public static void main(String[] args) throws DocumentException, 
IOException {
        Rectangle pageSize = PageSize.A4.rotate();
        Font font = new Font("SansSerif", Font.PLAIN, 12);

        Document document = new Document(pageSize);
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        PdfWriter writer = PdfWriter.getInstance(document, bos);
        document.open();

        PdfContentByte cb = writer.getDirectContent();

        Graphics2D g = cb.createGraphics(pageSize.getWidth(), 
pageSize.getHeight());
        g.setFont(font);

        g.drawString("A340", 100, 100);

        // forgetting to dispose of the graphics object will generate a PDF 
without warning, but Adober Reader will freeze on the first mouse click
        // g.dispose();

        document.close();

        FileOutputStream os = new FileOutputStream("c:/tmp/capabilities.pdf");
        os.write(bos.toByteArray());
        os.close();
    }

Thanks for your interest in the issue.

Regards
Stephen

PS:
On the off-chance that you can do something about it: It would be great (and 
compliant with 99.9 % of other software) if I could dismiss the "No (more) 
matches were found" dialog (after searching) in Reader by pressing "ESC". I 
just can't get it into my fingers to hit ENTER instead.


FORTIS IT-Services GmbH
Duvenstedter Damm 72
D-22397 Hamburg
T +49 (0)40 607699-22
F +49 (0)40 607699-20
M +49 (0)163 676 77 32
[email protected]<mailto:[email protected]>
http://www.fortis-it.de<http://www.fortis-it.de/>

Geschäftsführer:
Hubertus Bergmann, Joachim Bockhoff, Winald Kasch
HRB 85134, Sitz der Gesellschaft: Hamburg

Von: Leonard Rosenthol [mailto:[email protected]]
Gesendet: Dienstag, 14. April 2009 19:04
An: Post all your questions about iText here
Betreff: Re: [iText-questions] iText generated PDF hangs Adobe Reader 9.1

Can you please send me a copy of that PDF?

Thanks,
Leonard

From: Stephen Friedrich [mailto:[email protected]]
Sent: Tuesday, April 14, 2009 12:12 PM
To: [email protected]
Subject: [iText-questions] iText generated PDF hangs Adobe Reader 9.1

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.

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?

Attachment: capabilities.pdf
Description: capabilities.pdf

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

Reply via email to