List of usage examples for com.lowagie.text.pdf PdfPTable setExtendLastRow
public void setExtendLastRow(boolean extendLastRow)
From source file:questions.tables.AutomaticExtensionOfTables.java
public static void createPdf(int rows) throws IOException, DocumentException { Document document = new Document(PageSize.LETTER); PdfWriter.getInstance(document, new FileOutputStream(RESULT[rows])); document.open();/*from w w w . ja v a 2 s. c o m*/ PdfPTable outer = new PdfPTable(2); outer.setExtendLastRow(true); PdfPTable inner1 = new PdfPTable(5); for (int i = 0; i < ROWS[rows]; i++) { inner1.addCell("A" + i); inner1.addCell("B" + i); inner1.addCell("C" + i); inner1.addCell("D" + i); inner1.addCell("E" + i); } PdfPCell cell = new PdfPCell(inner1); cell.setColspan(2); outer.addCell(cell); PdfPTable inner2 = new PdfPTable(5); for (int i = 0; i < 20; i++) { inner2.addCell("testA"); } outer.addCell(inner2); PdfPTable inner3 = new PdfPTable(3); for (int i = 0; i < 20; i++) { inner3.addCell("testB"); } outer.addCell(inner3); document.add(outer); document.close(); }