Reputation: 449
I m using this code to give border radius to my pdfpcell
cell.Border = PdfPCell.NO_BORDER;
cell.CellEvent = new RoundedBorder();
Color color2 = new Color(System.Drawing.ColorTranslator.FromHtml("#2AB1C3"));
cell.BorderColor = new Color(System.Drawing.ColorTranslator.FromHtml("#2AB1C3"));
cell.BorderWidth = 2f;
and the function RoundedBorder
public class RoundedBorder : IPdfPCellEvent
{
public void CellLayout(PdfPCell cell, Rectangle rect, PdfContentByte[] canvas)
PdfContentByte cb = canvas[PdfPTable.BACKGROUNDCANVAS];
cb.RoundRectangle(
rect.Left + 1.5f,
rect.Bottom + 1.5f,
rect.Width - 3,
rect.Height - 3, 4
);
cb.Stroke();
}
}
I got rounded border but it is coming with black color and i want to give my custom color border to rounded radius
Can anyone help me on this ???
Upvotes: 2
Views: 4003
Reputation: 4871
Since you are configuring the PdfPCell
to have no border (cell.Border = PdfPCell.NO_BORDER
), setting border properties like border width and color won't have any effect.
You have to define the color of the stroke operation in your cell event, e.g. for a red border:
cb.SetRGBColorStroke(255, 0, 0);
cb.RoundRectangle(
rect.Left + 1.5f,
rect.Bottom + 1.5f,
rect.Width - 3,
rect.Height - 3, 4
);
cb.Stroke();
Upvotes: 2