Table Cell Color Demo : Table Cell Color « PDF RTF « Java






Table Cell Color Demo

Table Cell Color Demo
import java.awt.Color;
import java.io.FileOutputStream;

import com.lowagie.text.Document;
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 TableCellColorPDF {
  public static void main(String[] args) {
    Document document = new Document();

    try {
      PdfWriter.getInstance(document, new FileOutputStream("TableCellColorPDF.pdf"));
      document.open();

      PdfPTable table = new PdfPTable(1);
      PdfPCell cell = new PdfPCell(new Paragraph("cell test1"));
      cell.setBorderColor(new Color(255, 0, 0));
      table.addCell(cell);
      
      cell = new PdfPCell(new Paragraph("cell test2"));
      table.addCell(cell);
      
      document.add(table);
    } catch (Exception e) {
      System.err.println(e.getMessage());
    }
    document.close();
  }
}
           
       








itext.zip( 1,748 k)

Related examples in the same category

1.Table Cell with BackgroundTable Cell with Background
2.Cell Gray ScaleCell Gray Scale