我必须创建一个具有圆角的表格,如下所示:
![enter image description here](https://i.stack.imgur.com/N9Z5r.png)
我可以用 iTextSharp 做到这一点吗?
这是使用单元事件完成的。
请参阅我的书中的日历示例(Java / C#).
确保您没有向单元格添加任何“自动”边框,而是在单元格事件中自己绘制边框:
table.DefaultCell.Border = PdfPCell.NO_BORDER;
table.DefaultCell.CellEvent = new RoundedBorder();
The RoundedBorder
那么类将如下所示:
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.5、3 和 4 以获得不同的效果。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)