public void WriteBorderAndBackground(float xPos, float yPos, float currentMaxHeight, PdfPCell cell, PdfContentByte[] canvases)
{
BaseColor background = cell.BackgroundColor;
if (background != null || cell.HasBorders()) {
// Add xPos resp. yPos to the cell's coordinates for absolute coordinates
float right = cell.Right + xPos;
float top = cell.Top + yPos;
float left = cell.Left + xPos;
float bottom = top - currentMaxHeight;
if (background != null) {
PdfContentByte backgr = canvases[PdfPTable.BACKGROUNDCANVAS];
backgr.SetColorFill(background);
backgr.Rectangle(left, bottom, right - left, top - bottom);
backgr.Fill();
}
if (cell.HasBorders()) {
Rectangle newRect = new Rectangle(left, bottom, right, top);
// Clone non-position parameters except for the background color
newRect.CloneNonPositionParameters(cell);
newRect.BackgroundColor = null;
// Write the borders on the line canvas
PdfContentByte lineCanvas = canvases[PdfPTable.LINECANVAS];
lineCanvas.Rectangle(newRect);
}
}
}