NullPointerException when adding table to document
- From: KSchaeuble (at) netzgiganten.de
- Date: Fri, 25 Aug 2006 11:31:09 +0200
I think I could narrow it down a bit though I'm still clueless, what is
excactly happening.
I'm adding a Paragraph to a cell like this:
Paragraph para = (Paragraph)element.render(style);
contentCell.addElement(para);
The render-method returns an Element, but if I ask element.render(style)
what its type is it correctly answers it is a Paragraph. I can also get
the content which is also correct.
But when I use the above I get in the end:
DocumentException:
java.lang.NullPointerException
at com.lowagie.text.Phrase.leading(Unknown Source)
at com.lowagie.text.pdf.ColumnText.goComposite(Unknown Source)
at com.lowagie.text.pdf.ColumnText.go(Unknown Source)
at com.lowagie.text.pdf.PdfPRow.calculateHeights(Unknown Source)
at com.lowagie.text.pdf.PdfPRow.getMaxHeights(Unknown Source)
at com.lowagie.text.pdf.PdfPTable.calculateHeights(Unknown Source)
at com.lowagie.text.pdf.PdfPTable.setTotalWidth(Unknown Source)
at com.lowagie.text.pdf.ColumnText.goComposite(Unknown Source)
at com.lowagie.text.pdf.ColumnText.go(Unknown Source)
at com.lowagie.text.pdf.ColumnText.go(Unknown Source)
at com.lowagie.text.pdf.PdfDocument.addPTable(Unknown Source)
at com.lowagie.text.pdf.PdfDocument.add(Unknown Source)
at com.lowagie.text.Document.add(Unknown Source)
at pmt.reporting.basereporting.ReportGenerator.generateReport(
ReportGenerator.java:73)
If I do the following I get no exception:
Paragraph para = (Paragraph)element.render(style);
contentCell.addElement(new Paragraph(para.content()));
So I guess something gets lost somehow.
Please help I'm really despairing of that!
KSchaeuble (at) netzgiganten.de
Sent by: itext-questions-bounces (at) lists.sourceforge.net
25.08.2006 10:10
Please respond to
Post all your questions about iText here
<itext-questions (at) lists.sourceforge.net>
To
itext-questions (at) lists.sourceforge.net
cc
Subject
[iText-questions] NullPointerException when adding table to document
I'm trying to piece a report together by creating several parts in
different classes. I first ran this code locally and had no prblems
creating the Pdf. When I now integrate it into my web-app and use a real
object I'm getting an exception while generating the document:
I tried to hunt it down but now am rather clueless where else to look. I
already checked that the text I'm getting from the object is ok.
This is the exception I'm getting:
DocumentException:
java.lang.NullPointerException
at com.lowagie.text.pdf.PdfChunk.<init>(Unknown Source)
at com.lowagie.text.pdf.ColumnText.addWaitingPhrase(Unknown
Source)
at com.lowagie.text.pdf.ColumnText.go(Unknown Source)
at com.lowagie.text.pdf.PdfPRow.calculateHeights(Unknown Source)
at com.lowagie.text.pdf.PdfPRow.getMaxHeights(Unknown Source)
at com.lowagie.text.pdf.PdfPTable.calculateHeights(Unknown Source)
at com.lowagie.text.pdf.PdfPTable.setTotalWidth(Unknown Source)
at com.lowagie.text.pdf.ColumnText.goComposite(Unknown Source)
at com.lowagie.text.pdf.ColumnText.go(Unknown Source)
at com.lowagie.text.pdf.PdfPRow.calculateHeights(Unknown Source)
at com.lowagie.text.pdf.PdfPRow.getMaxHeights(Unknown Source)
at com.lowagie.text.pdf.PdfPTable.calculateHeights(Unknown Source)
at com.lowagie.text.pdf.PdfPTable.setTotalWidth(Unknown Source)
at com.lowagie.text.pdf.ColumnText.goComposite(Unknown Source)
at com.lowagie.text.pdf.ColumnText.go(Unknown Source)
at com.lowagie.text.pdf.ColumnText.go(Unknown Source)
at com.lowagie.text.pdf.PdfDocument.addPTable(Unknown Source)
at com.lowagie.text.pdf.PdfDocument.add(Unknown Source)
at com.lowagie.text.Document.add(Unknown Source)
at pmt.reporting.basereporting.ReportGenerator.generateReport(
ReportGenerator.java:57)
And this is where I add my table. The render-method returns a PdfPTable as
expected:
List firstElements = builder.getFirstElements();
for (Iterator iter = firstElements.iterator(); iter.hasNext();) {
ReportSection firstElement = (ReportSection) iter.next();
PdfPTable table = new
PdfPTable((PdfPTable)firstElement.render(style));
document.add(table);
}
I know my description is rather misty but maybe you can give me at least
an idea where else to look.
Thanks a lot!
Karola
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job
easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
iText-questions mailing list
iText-questions (at) lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
iText-questions mailing list
iText-questions (at) lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions