Split Table Rows : Table Row « PDF « Java Tutorial






import java.io.FileOutputStream;
import java.io.IOException;

import com.lowagie.text.Document;
import com.lowagie.text.DocumentException;
import com.lowagie.text.PageSize;
import com.lowagie.text.Paragraph;
import com.lowagie.text.pdf.PdfPCell;
import com.lowagie.text.pdf.PdfPTable;
import com.lowagie.text.pdf.PdfWriter;

public class MainClass {
  public static void main(String[] args) throws Exception {
    Document document1 = new Document(PageSize.A4.rotate());
      PdfWriter.getInstance(document1, new FileOutputStream(
          "2.pdf"));

      document1.open();

      String text = "Quick brown fox jumps over the lazy dog.";
      PdfPTable table = new PdfPTable(2);
      PdfPCell largeCell = new PdfPCell();
      for (int i = 1; i < 13; i++) {
        largeCell.addElement(new Paragraph(String.valueOf(i) + text));
      }
      for (int i = 1; i < 11; i++) {
         table.addCell(largeCell);
      }
      document1.add(table);
      table.setSplitLate(false);
      document1.add(table);
      table.setSplitRows(false);
      document1.add(table);

    document1.close();
  }
}








29.57.Table Row
29.57.1.Split Table Rows
29.57.2.Set table total width
29.57.3.Write Selected Rows in a Table
29.57.4.What if table is larger than the page
29.57.5.Ouput selected rows from a table
29.57.6.Loop through all rows from Table