我想使用 itextpdf 在单元格的 4 个边框中设置 4 种不同的颜色。当我使用下面的代码时,它不起作用。请帮我解决这个问题。
private static PdfPTable insertCell(PdfPTable table, String text, int align, int colspan, Font font){
PdfPCell cell = new PdfPCell(new Phrase(text.trim(), font));
cell.setHorizontalAlignment(align);
cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
cell.setColspan(colspan);
cell.setBackgroundColor(new BaseColor(hex2Rgb(color)));
cell.setBorderColorTop(BaseColor.BLUE);
cell.setBorderWidthTop(1f);
cell.setBorder(Rectangle.TOP);
cell.setBorderColorRight(BaseColor.ORANGE);
cell.setBorderWidthRight(1f);
cell.setBorder(Rectangle.RIGHT);
cell.setBorderColorBottom(BaseColor.RED);
cell.setBorderWidthBottom(1f);
cell.setBorder(Rectangle.BOTTOM);
cell.setBorderColorLeft(BaseColor.GREEN);
cell.setBorderWidthLeft(1f);
cell.setBorder(Rectangle.LEFT);
cell.setMinimumHeight(25f);
//add the call to the table
table.addCell(cell);
return table;
}