In what way is this related to iText? Paulo
> -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On > Behalf Of "Tim Tönnsen" > Sent: Tuesday, June 03, 2008 3:54 PM > To: itext-questions@lists.sourceforge.net > Subject: [iText-questions] NullPointerException in onEndPage > > Hi Everybody, > > in the moment I am writing an application for a Customer. One > functionality is the option to generate a pdf-file. To do > this, I wrote a Controller which extends the > PdfPageEventHelper. the Controller has a print(DataObject > toPrint) method. These PrintMethod prints the Data's given as > the parameter "toPrint", but first of all the toPrint Object > is stored in a global variable. Everything worked fine until > I overrids the onPageEnd Method, to generate a Header. The > problem is that the global Variable holding the data to be > printed is null, althought is was set by the call of the > print method. Unfortunately, I am not allowed to send the > complete code, but I added a bit pseudoCode to ilustrate the > Problem a bit Better: > > public class PdfController extends PdfPageEventHelper > { > private DataObject data; > > public void print(DataObject toPrint) > { > this.data = toPrint; > Document document = new Document(PageSize.A4, 50, 50, 100, 70); > PdfWriter writer = PdfWriter.getInstance(document, new > FileOutputStream("HelloWorld.pdf")); > document.open(); > //do some PDF-Generation Stuff, depending on which kind > of data is in "data" > document.newPage(); > //do some PDF-Generation Stuff, depending on which kind > of data is in "data" > document.close(); > } > > public void onEndPage(PdfWriter writer, Document document) > { > //setup the header > PdfPTable table = new PdfPTable(1); > table.addCell((String)data.getFirstHeaderElement()); > head.addCell(table); > //do some more stuff.. > } > } > > In the Line > table.addCell((String)data.getFirstHeaderElement()); in the > onEndPageMethod I get an NullPointerException, during > debugging I saw, that "data" is set directly before the call > of "document.newPage();" but in the "onPageEnd"-Method it is > null. Can you tell me what the Problem is, and how to solve > it? Thanks a million > > armerIrrer Aviso Legal: Esta mensagem é destinada exclusivamente ao destinatário. Pode conter informação confidencial ou legalmente protegida. A incorrecta transmissão desta mensagem não significa a perca de confidencialidade. Se esta mensagem for recebida por engano, por favor envie-a de volta para o remetente e apague-a do seu sistema de imediato. É proibido a qualquer pessoa que não o destinatário de usar, revelar ou distribuir qualquer parte desta mensagem. Disclaimer: This message is destined exclusively to the intended receiver. It may contain confidential or legally protected information. The incorrect transmission of this message does not mean the loss of its confidentiality. If this message is received by mistake, please send it back to the sender and delete it from your system immediately. It is forbidden to any person who is not the intended receiver to use, distribute or copy any part of this message. ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ _______________________________________________ iText-questions mailing list iText-questions@lists.sourceforge.net 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