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 -- Super-Aktion nur in der GMX Spieleflat: 10 Tage für 1 Euro. Über 180 Spiele downloaden: http://flat.games.gmx.de ------------------------------------------------------------------------- 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