我不确定此错误消息实际指向的是什么。要清楚,我知道NullPointerException是什么,但我无法弄清楚什么是null,不应该是。有人知道导致此错误的原因是什么?
感谢。
com.lowagie.text.DocumentException: java.lang.NullPointerException
at com.lowagie.text.pdf.PdfDocument.add(Unknown Source)
at com.lowagie.text.Document.add(Unknown Source)
...
Caused by: java.lang.NullPointerException
at com.lowagie.text.pdf.PdfPTable.getRowHeight(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.PdfPCell.getMaxHeight(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.getRowHeight(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)
... 97 more
有问题的代码:
this.getDocument().open();
Element body = this.getBody();
System.out.println(body);
System.out.println(this.getDocument().toString());
this.getDocument().add(body);//it errors out here!
this.getDocument().close();
调试语句返回:
com.lowagie.text.pdf.PdfPTable@1fa0c8f
com.lowagie.text.Document@14eb497
答案 0 :(得分:1)
我得到了完全相同的错误和堆栈跟踪,并通过切换到OpenPDF来解决问题。
OpenPDF基于iText 4,并有一些额外的错误修复和NPE修复。 正在积极维护OpenPDF。