C# ITextSharp如何将矩形参数传递给方法以设置边框
下面是我在SO上找到的一个示例,用于将单元格添加到PdfPTable中,并将其外推到一个方法中,我创建了一个方法,用于设置除cell.Border的矩形值之外的所有参数。如何修复我的方法,以便传入所需的任何矩形值 矩形是从ITextSharp中的元素IELENT派生的对象 可能的矩形值为: 矩形。左边框,矩形。上边框,矩形。右边框,矩形。下边框,矩形。无边框 或可通过其数值访问: 下边框=2,左边框=4,无边框=0,右边框=8,上边框=1 示例:cell.Border=1 | 2 | 8;或cell.Border=Rectangle.TOP_Border | Rectangle.RIGHT_Border 挂起我的是必须在值和单元格之间的“|” 方法如下:C# ITextSharp如何将矩形参数传递给方法以设置边框,c#,itext,C#,Itext,下面是我在SO上找到的一个示例,用于将单元格添加到PdfPTable中,并将其外推到一个方法中,我创建了一个方法,用于设置除cell.Border的矩形值之外的所有参数。如何修复我的方法,以便传入所需的任何矩形值 矩形是从ITextSharp中的元素IELENT派生的对象 可能的矩形值为: 矩形。左边框,矩形。上边框,矩形。右边框,矩形。下边框,矩形。无边框 或可通过其数值访问: 下边框=2,左边框=4,无边框=0,右边框=8,上边框=1 示例:cell.Border=1 | 2 | 8;或ce
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);
}
我的问题的答案是将适当的值作为int传递到方法中。矩形值具有数值,调用将它们相加为一个数字,并传递给方法。这有一个特定的术语,但我现在想不起来
addCell(tableName, "MyPhrase", 1, 1, MyFont, Rectangle.BOTTOM_BORDER | Rectangle.RIGHT_BORDER;
private static void addCell(PdfPTable table, string phrase, int colspan, int height, Font font, int border)
{
PdfPCell cell = new PdfPCell(new Phrase(phrase, font));
cell.Border = border;
cell.BorderWidth = 1;
cell.Colspan = colspan;
cell.FixedHeight = height;
table.AddCell(cell);
}
挂起我的是必须在值和单元格之间的“|”。边框将不接受字符串;-为什么or运算符应该接受字符串?你为什么期望它这样做?