Following an example I found on SO (how to set width for pdfpcell) for extrapolating adding a cell to a PdfPTable into a method I have created one that sets all my parameters except the Rectangle values for cell.Border. How do I fix my method so I can pass in any Rectangle values I need?
Rectangle is and object derived from Element, IElement in ITextSharp.
Potential Rectangle values are:
Rectangle.LEFT_BORDER, Rectangle.TOP_BORDER, Rectangle.RIGHT_BORDER, Rectangle.BOTTOM_BORDER, Rectangle.NO_BORDER
or can be accessed by their numerical values:
BOTTOM_BORDER = 2, LEFT_BORDER = 4, NO_BORDER = 0, RIGHT_BORDER = 8, TOP_BORDER = 1
Example: cell.Border = 1 | 2 | 8; or cell.Border = Rectangle.TOP_BORDER | Rectangle.RIGHT_BORDER;
What's hanging me up is the '|' that has to be between the values and cell.Border will not accept a string;
Here is the method:
private static void addCell(PdfPTable table, string phrase, int colspan, int height, Font font)
{
PdfPCell cell = new PdfPCell(new Phrase(phrase, font));
cell.Border = Rectangle.TOP_BORDER | Rectangle.BOTTOM_BORDER; ** need to set param here **
cell.BorderWidth = 1;
cell.Colspan = colspan;
cell.FixedHeight = height;
table.AddCell(cell);
}