我使用此代码为我的 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();
}
}
我有圆形边框,但它是黑色的,我想将我的自定义颜色边框设置为圆形半径
谁能帮我解决这个问题???
最佳答案
由于您将 PdfPCell
配置为没有边框 (cell.Border = PdfPCell.NO_BORDER
),因此设置边框属性(例如边框宽度和颜色)不会有任何边框效果。
您必须在单元格事件中定义笔画操作的颜色,例如红色边框:
cb.SetRGBColorStroke(255, 0, 0);
cb.RoundRectangle(
rect.Left + 1.5f,
rect.Bottom + 1.5f,
rect.Width - 3,
rect.Height - 3, 4
);
cb.Stroke();
关于c# - 在itextsharp中为pdfpcell添加圆形颜色边框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33046706/