如何使用iText \ iTextSharp创建圆角桌?

我必须创建一个圆角的桌子,类似于:

在此处输入图像描述

我可以用iTextSharp做到吗?

这是使用单元格事件完成的。

请参阅我的书中的日历示例( Java / C# )。

确保不向单元格添加任何“自动”边框,但在单元格事件中自己绘制边框:

table.DefaultCell.Border = PdfPCell.NO_BORDER; table.DefaultCell.CellEvent = new RoundedBorder(); 

然后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以获得不同的效果。