public void CellLayout(PdfPCell cell, Rectangle position,
PdfContentByte[] canvases)
{
float effectivePadding = styleValues.BorderWidthLeft/2 + styleValues.HorBorderSpacing;
float x1 = position.Left + effectivePadding;
if (styleValues.IsLastInRow){
effectivePadding = styleValues.BorderWidthRight/2 + styleValues.HorBorderSpacing;
} else {
effectivePadding = styleValues.BorderWidthRight/2;
}
float x2 = position.Right - effectivePadding;
effectivePadding = styleValues.BorderWidthTop/2 + styleValues.VerBorderSpacing;
float y1 = position.Top - effectivePadding;
effectivePadding = styleValues.BorderWidthBottom/2;
float y2 = position.Bottom + effectivePadding;
PdfContentByte cb = canvases[PdfPTable.LINECANVAS];
BaseColor color = styleValues.Background;
if (color != null) {
cb.SetColorStroke(color);
cb.SetColorFill(color);
cb.Rectangle(x1, y1, x2-x1, y2-y1);
cb.Fill();
}
BaseColor borderColor = styleValues.BorderColorLeft;
float width = styleValues.BorderWidthLeft;
if (borderColor != null && width != 0) {
cb.SetLineWidth(width);
cb.SetColorStroke(borderColor);
cb.MoveTo(x1, y1); // start leftUpperCorner
cb.LineTo(x1, y2); // left
cb.Stroke();
}
borderColor = styleValues.BorderColorBottom;
width = styleValues.BorderWidthBottom;
if (borderColor != null && width != 0) {
cb.SetLineWidth(width);
cb.SetColorStroke(borderColor);
cb.MoveTo(x1, y2); // left
cb.LineTo(x2, y2); // bottom
cb.Stroke();
}
borderColor = styleValues.BorderColorRight;
width = styleValues.BorderWidthRight;
if (borderColor != null && width != 0) {
cb.SetLineWidth(width);
cb.SetColorStroke(borderColor);
cb.MoveTo(x2, y2); // bottom
cb.LineTo(x2, y1); // right
cb.Stroke();
}
borderColor = styleValues.BorderColorTop;
width = styleValues.BorderWidthTop;
if (borderColor != null && width != 0) {
cb.SetLineWidth(width);
cb.SetColorStroke(borderColor);
cb.MoveTo(x2, y1); // right
cb.LineTo(x1, y1); // top
cb.Stroke();
}
cb.ResetRGBColorStroke();
}