我使用此代码为我的pdfpcell提供边界半径
cell.Border = PdfPCell.NO_BORDER;
cell.CellEvent = new RoundedBorder();
Color color2 = new Color(System.Drawing.ColorTranslator.FromHtml("#2AB1C3"));
cell.BorderColor = new Color(System.Drawing.ColorTranslator.FromHtml("#2AB1C3"));
cell.BorderWidth = 2f;
和函数RoundedBorder
public class RoundedBorder : IPdfPCellEvent
{
public void CellLayout(PdfPCell cell, Rectangle rect, PdfContentByte[] canvas)
PdfContentByte cb = canvas[PdfPTable.BACKGROUNDCANVAS];
cb.RoundRectangle(
rect.Left + 1.5f,
rect.Bottom + 1.5f,
rect.Width - 3,
rect.Height - 3, 4
);
cb.Stroke();
}
}
我有圆形边框,但它是黑色的,我想给我的自定义颜色边框圆角半径
谁可以帮我这个事 ???
1 回答
由于您将
PdfPCell
配置为没有边框(cell.Border = PdfPCell.NO_BORDER
),因此设置边框宽度和颜色等边框属性将不起任何作用 .您必须在单元格事件中定义笔划操作的颜色,例如为红色边框: