Java 调用iText 5.4.4中的新章节(int)时出现NullPointerException
在将本章添加到文档中之后,我尝试将节添加到章节中。 这是我的密码:Java 调用iText 5.4.4中的新章节(int)时出现NullPointerException,java,itext,Java,Itext,在将本章添加到文档中之后,我尝试将节添加到章节中。 这是我的密码: Chapter chapter = new Chapter("chapter1", 1); chapter.addSection("section1"); document.add(chapter); chapter = new Chapter(1); chapter.addSection("section2"); document.add(chapter); 这适用于5.0.4版本的书籍版本,但在最新的5.4.4版本中失败
Chapter chapter = new Chapter("chapter1", 1);
chapter.addSection("section1");
document.add(chapter);
chapter = new Chapter(1);
chapter.addSection("section2");
document.add(chapter);
这适用于5.0.4版本的书籍版本,但在最新的5.4.4版本中失败。我在chapter=newchapter1;行中得到了NullPointerException
以下是错误堆栈:
Exception in thread "main" java.lang.NullPointerException
at com.itextpdf.text.Section.<init>(Section.java:176)
at com.itextpdf.text.Chapter.<init>(Chapter.java:82)
at mihoTest.MihoTest03.main(MihoTest03.java:36)
Jus wonde新章节的正确名称是什么。您发现了一个bug。它已在SVN存储库中修复:
创建没有标题的章节时会出现问题。听起来像个bug。如果让我猜的话,我猜在添加对带标签PDF的支持时出现了一个问题。我在iText支持系统上做了一个内部记录。谢谢你,布鲁诺。你的书很棒。如果您可以在下一个版本中添加一个创建带有页码的TOC的示例,那将是完美的。