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