How to create a table with rounded corners?

Tags: tablescell eventcell borderrounded cornersiText 7

I have to create a table having rounded corners, something like it:

Cell with rounded border

Can I do it with iTextSharp?

Posted on StackOverflow on May 14, 2014 by AndreaNobili

In iText 7 this is done using cell renderers. You should set such renderer for your cell:

cell.setNextRenderer(new RoundedBorderCellRenderer(cell));

The RoundedBorderCellRenderer class would then look like this:

private class RoundedBorderCellRenderer extends CellRenderer {
    public RoundedBorderCellRenderer(Cell modelElement) {
    public void draw(DrawContext drawContext) {
        drawContext.getCanvas().roundRectangle(getOccupiedAreaBBox().getX() + 1.5f, getOccupiedAreaBBox().getY() + 1.5f,
                getOccupiedAreaBBox().getWidth() - 3, getOccupiedAreaBBox().getHeight() - 3, 4);

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

Click this link if you want to see how to answer this question in iText 5.