You must use Document, not PdfDocument.

Paulo

----- Original Message ----- 
From: "Kerry Wilson" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Monday, April 14, 2008 6:43 PM
Subject: [iText-questions] Null Pointer Exception


Anyone experienced this?  The following code yields a NullPointerException 
exception.  An empty file test.pdf is created but the open method call 
throws a null pointer for some reason.

CODE:

try {

        PdfDocument document = new PdfDocument();
        PdfWriter writer = PdfWriter.getInstance(document,new 
java.io.FileOutputStream("test.pdf"));
        document.open();
        Paragraph content = new Paragraph("Hello World");
        document.add( content );
        document.close();

} catch( Exception e ) {
        e.printStackTrace();
      }


EXCEPTION:

java.lang.NullPointerException
        at com.lowagie.text.pdf.PdfDocument.open(Unknown Source)


Thanks for any help


Kerry Wilson
Lead Developer
Williams Web
(423) 485-4747


-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Do you like iText?
Buy the iText book: http://www.1t3xt.com/docs/book.php
Or leave a tip: https://tipit.to/itexttipjar

Reply via email to