Convert2pdfptable : Table « PDF RTF « Java






Convert2pdfptable

Convert2pdfptable
import java.io.FileOutputStream;

import com.lowagie.text.Cell;
import com.lowagie.text.Document;
import com.lowagie.text.Table;
import com.lowagie.text.pdf.PdfWriter;

public class Convert2pdfptable {
  public static void main(String[] args) {
    Document document = new Document();
    try {
      PdfWriter.getInstance(document, new FileOutputStream("Convert2pdfptable.pdf"));

      document.open();

      Table table = new Table(2);
      table.setBorderWidth(1);
      table.setPadding(10);
      Cell cell = new Cell("header");
      cell.setHeader(true);
      cell.setColspan(2);
      table.addCell(cell);
      table.addCell("1.1");
      table.addCell("2.1");
      
      table.addCell("3.1");
      table.addCell("1.2");
      
      table.addCell("2.2");
      table.addCell("3.2");
      table.setConvert2pdfptable(true);
      document.add(table);

    } catch (Exception e) {
      System.err.println(e.getMessage());
    }
    document.close();
  }
}

           
       








Related examples in the same category

1.Table Width PercentageTable Width Percentage
2.PdfPTable: WriteSelectedRowsPdfPTable: WriteSelectedRows
3.Table Column, Row CountTable Column, Row Count
4.Extending PdfPTable LastRowExtending PdfPTable LastRow