Example usage for com.lowagie.text.pdf PdfPTable setExtendLastRow

List of usage examples for com.lowagie.text.pdf PdfPTable setExtendLastRow

Introduction

In this page you can find the example usage for com.lowagie.text.pdf PdfPTable setExtendLastRow.

Prototype

public void setExtendLastRow(boolean extendLastRow) 

Source Link

Document

When set the last row will be extended to fill all the remaining space to the bottom boundary.

Usage

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();
}