iText pdf library
Website search

How to create a table with rounded corners?

How do I do this?

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

Cell with rounded borderPosted 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.


Still have questions? 

We're happy to answer your questions. Reach out to us and we'll get back to you shortly.

Contact us
Stay updated

Join 11,000+ subscribers and become an iText PDF expert by staying up to date with our new products, updates, tips, technical solutions and happenings.

Subscribe Now