On creating a table having rounded corner with itext, the size of PDF is increasing unexpectedly

I am creating multiple table on the same PDF. I need the rounded corner of table also the border color of cell and border color of table should be different. I have created the table renderer for the same, while creating the table with the renderer, the PDF size is increasing randomly. If we are not using the round corner the PDF size is "61KB" & if I am using the renderer to make round corners then PDF of size is "500KB". Please suggest how to fix

import java.io.FileNotFoundException;
import com.itextpdf.kernel.colors.Color;
import com.itextpdf.kernel.colors.DeviceRgb;
import com.itextpdf.kernel.geom.Rectangle;
import com.itextpdf.kernel.pdf.PdfDocument;
import com.itextpdf.kernel.pdf.PdfPage;
import com.itextpdf.kernel.pdf.PdfWriter;
import com.itextpdf.kernel.pdf.canvas.PdfCanvas;
import com.itextpdf.layout.Document;
import com.itextpdf.layout.borders.SolidBorder;
import com.itextpdf.layout.element.Paragraph;
import com.itextpdf.layout.element.Table;
import com.itextpdf.layout.element.Text;
import com.itextpdf.layout.property.TextAlignment;
import com.itextpdf.layout.property.VerticalAlignment;
import com.itextpdf.layout.renderer.DrawContext;
import com.itextpdf.layout.renderer.IRenderer;
import com.itextpdf.layout.renderer.TableRenderer;

public class testDate {

public static void main(String[] args) throws FileNotFoundException {
    String dest = "D://PDF_SIZE.pdf";
    PdfWriter writer = new PdfWriter(dest);
    PdfDocument pdf = new PdfDocument(writer);
    pdf.addNewPage();
    Document doc = new Document(pdf);
    for (int i =0 ; i< 1130 ; i++){
        Table table = new Table(new float[]{100f,100f});
        table.setWidth(506.25f);
        table.setProperty(com.itextpdf.layout.property.Property.TABLE_LAYOUT, "fixed");

        com.itextpdf.layout.element.Cell cell = new com.itextpdf.layout.element.Cell(1,1);
        cell.setWidth(15.165f);
        Text t =new Text("A").setFontSize(11f);
        Paragraph p = new Paragraph();
        p.setFixedLeading(0.0f).setMultipliedLeading(0.86f);
        cell.add(p.add(t));
        cell.setPadding(3f);
        cell.setMinHeight(10f);
        cell.setVerticalAlignment(VerticalAlignment.TOP);
        cell.setTextAlignment(TextAlignment.LEFT);
        cell.setKeepTogether(true);
        cell.setBorder(new SolidBorder(new DeviceRgb(255,0,0),0.5f));
        cell.setBackgroundColor(new DeviceRgb(255,255,255));
        table.addCell(cell);

        com.itextpdf.layout.element.Cell cell2 = new com.itextpdf.layout.element.Cell(1,1);
        cell2.setWidth(490.33502f);
        Text t2 =new Text("Row Number - " + i).setFontSize(11f);
        Paragraph p2 = new Paragraph();
        p2.setFixedLeading(0.0f).setMultipliedLeading(0.86f);
        cell2.add(p2.add(t2));
        cell2.setPadding(3f);
        cell2.setMinHeight(10f);
        cell2.setVerticalAlignment(VerticalAlignment.TOP);
        cell2.setTextAlignment(TextAlignment.LEFT);
        cell.setKeepTogether(true);
        cell2.setBorder(new SolidBorder(new DeviceRgb(255,0,0),0.5f));
        cell2.setBackgroundColor(new DeviceRgb(255,255,255));
        table.addCell(cell2);
        table.setNextRenderer(new TableBorderRenderer (table));
        doc.add(table);

    }
    doc.close();
    System.out.println("table Added.");
}


public static  class TableBorderRenderer extends TableRenderer {


    public TableBorderRenderer(Table modelElement) {
        super(modelElement);

    }

    @Override
    public IRenderer getNextRenderer() {
        return new TableBorderRenderer((Table) modelElement);
    }


    @Override
    protected void drawBorders(DrawContext drawContext) {
        Rectangle rect = getOccupiedAreaBBox();
        PdfPage currentPage = drawContext.getDocument().getPage(getOccupiedArea().getPageNumber());

        PdfCanvas aboveCanvas = new PdfCanvas(currentPage.newContentStreamAfter(), currentPage.getResources(), drawContext.getDocument());
        float lineWidth = 0.5f;
        rect.applyMargins(lineWidth / 2, lineWidth / 2, lineWidth / 2, lineWidth / 2, false);
        Color strokeColor;
        strokeColor = new DeviceRgb(255,255,0);
        aboveCanvas.saveState().setLineWidth(0.5f).setStrokeColor(new DeviceRgb(255,255,255)).rectangle(rect).stroke().restoreState();
        aboveCanvas.saveState().setLineWidth(0.5f).setStrokeColor(strokeColor).roundRectangle(rect.getLeft(), rect.getBottom(), rect.getWidth(), rect.getHeight(), 5).stroke().restoreState();
        super.drawBorders(drawContext);
    }

    @Override
    public void drawChildren(DrawContext drawContext) {
        Rectangle rect = getOccupiedAreaBBox();
        float lineWidth = 0.5f;
        rect.applyMargins(lineWidth, lineWidth, lineWidth, lineWidth, false);
        PdfCanvas canvas = drawContext.getCanvas();
        canvas.saveState();
        canvas.roundRectangle(rect.getLeft(), rect.getBottom(), rect.getWidth(), rect.getHeight(), 4.5f);
        canvas.clip().endPath();
        super.drawChildren(drawContext);
        canvas.restoreState();
    }
    }
}

Since you create a table inside rather than outside the loop, you create 1130 tables rather than 1. This is the biggest issue, which prevents you from harnessing the idea of the SO answer you mentioned in the comments.

If you place table creation outside the loop just as I do in the following snippet, then the size of the resultant PDF gets reduced from 521 Kb to 51 Kb. If you disable setting a custom table renderer for such a code, then the resultant PDF will be of 45 Kb size.

    Table table = new Table(new float[] {100f, 100f});
    table.setWidth(506.25f);
    table.setFixedLayout();

    for (int i =0 ; i < 1130 ; i++) {
        // each iteration of this loop represents adding of a single row
        // some code
    }

    doc.add(table);

This is how the resultant PDF looks like now: enter image description here

As you asked in the question, it has yellow rounded table borders, cell background (which you set to white in your code) and red cell borders.