Here's an example.
You need to create a custom IPdfPCellEvent
implementation.
private class MyEvent : IPdfPCellEvent {
string number;
public MyEvent(string number) {
this.number = number;
}
public void CellLayout(PdfPCell cell, Rectangle position, PdfContentByte[] canvases) {
ColumnText.ShowTextAligned(
canvases[PdfPTable.TEXTCANVAS],
Element.ALIGN_LEFT,
new Phrase(number),
position.Left + 2, position.Top - 16, 0);
}
}
As you can see, we add a Phrase
with the content number
at an absolute position. In this case: 2 user units apart from the left border of the cell and 16 user units below the top of the cell.
In your code snippet you then add:
cell.CellEvent = new my_event(n);
Where n
is the string value of number
. Now the number will be drawn every time a cell is rendered.