我想补充一些“多行和列”的表单元格,但得到
IndexOutOfBoundsException异常。
任何帮助将不胜感激。
谢谢!
public static void main(String[] args) throws FileNotFoundException {
PdfWriter writer = new PdfWriter("D:\\test.pdf");
PdfDocument pdf = new PdfDocument(writer);
Document document = new Document(pdf);
Table table = new Table(10);
table.setWidthPercent(100);
table.addCell(new Cell(1, 3).add(new Paragraph(1 + "_" + 3 + "_")));
table.addCell(new Cell(1, 7).add(new Paragraph(1 + "_" + 4 + "_")));
table.addCell(new Cell(6, 1).add(new Paragraph(6 + "_" + 1 + "_")));
table.addCell(new Cell(6, 9).add(new Paragraph(6 + "_" + 9 + "_")));
table.flushContent();
document.add(table);
document.close();
}
例外
java.lang.IndexOutOfBoundsException: Index: 2, Size: 2
at java.util.ArrayList.rangeCheck(ArrayList.java:653)
at java.util.ArrayList.get(ArrayList.java:429)
at com.itextpdf.layout.renderer.TableRenderer.drawVerticalBorder(TableRenderer.java:1718)
at com.itextpdf.layout.renderer.TableRenderer.drawBorders(TableRenderer.java:1619)
at com.itextpdf.layout.renderer.TableRenderer.drawChildren(TableRenderer.java:1265)
at com.itextpdf.layout.renderer.AbstractRenderer.draw(AbstractRenderer.java:437)
at com.itextpdf.layout.renderer.TableRenderer.draw(TableRenderer.java:1175)
at com.itextpdf.layout.renderer.DocumentRenderer.flushSingleRenderer(DocumentRenderer.java:118)
at com.itextpdf.layout.renderer.RootRenderer.processRenderer(RootRenderer.java:287)
at com.itextpdf.layout.renderer.RootRenderer.updateCurrentAreaAndProcessRenderer(RootRenderer.java:300)
at com.itextpdf.layout.renderer.RootRenderer.addChild(RootRenderer.java:201)
at com.itextpdf.layout.RootElement.add(RootElement.java:108)
at com.itextpdf.layout.Document.add(Document.java:143)