I am trying to draw a circle inside a PdfPCell. I have seen examples on how to do this, and I can draw a circle anywhere on the paper. However, all these examples use fixed coordinates and circle radius.
What I want is to put the circle inside the cell, and make it as big as the cell. I am using this code:
PdfPCell cell = new PdfPCell();
cell.setPhrase(new Phrase("A"));
table.addCell(cell);
canvas.circle(cell.getLeft(), cell.getBottom(), cell.getWidth() / 2f);
canvas.stroke();
However, cell.getLeft(), cell.getBottom() and cell.getWidth() they all return 0, always.
How can I get the position of the cell in the page?
You need to implement the PdfPCellEvent (
cell.setCellEvent(...)) and thenpublic void cellLayout(PdfPCell cell, Rectangle rect, PdfContentByte[] canvas)gives you the exact coordinates of the current cell.