Legacy notice!

iText 5 is the previous major version of iText's leading PDF SDK. iText 5 has been EOL, and is no longer developed. Switch your project to iText 7, integrating the latest developments.
Check related iText 7 content!

I have to create a table having with rounded corners. Can I do it with iTextSharp?

I want something like this:

Cell with rounded borderCan I do it with iTextSharp?

Posted on StackOverflow on May 14, 2014 by AndreaNobili

This is done using cell events.

Make sure that you don't add any "automated" borders to the cell, but draw the borders yourself in a cell event:

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

The RoundedBorder class would then look like this:

class RoundedBorder : IPdfPCellEvent {
  public void CellLayout(PdfPCell cell, Rectangle rect, PdfContentByte[] canvas) {
    PdfContentByte cb = canvas[PdfPTable.BACKGROUNDCANVAS];
      rect.Left + 1.5f,
      rect.Bottom + 1.5f,
      rect.Width - 3,
      rect.Height - 3, 4

You can of course fine-tune the values 1.5, 3 and 4 to get different effects.