C# ItextSharp文本操作

C# ItextSharp文本操作,c#,C#,如何将此文本设置为单元格的中心并添加单元格的背景?以下是示例代码: table.AddCell(new Paragraph("Sample text", font)); 希望这能起作用。什么元素是“表”?PdfPTable table=新的PdfPTable(5) PdfPCell c; c = new PdfPCell(new Paragraph(@"Sample text", font)); c.HorizontalAlignment = Element.ALIGN

如何将此文本设置为单元格的中心并添加单元格的背景?

以下是示例代码:

table.AddCell(new Paragraph("Sample text", font));

希望这能起作用。

什么元素是“表”?
PdfPTable table=新的PdfPTable(5)
    PdfPCell c;
    c = new PdfPCell(new Paragraph(@"Sample text", font));
    c.HorizontalAlignment = Element.ALIGN_CENTER;
    c.VerticalAlignment = Element.ALIGN_MIDDLE;
    c.BackgroundColor = iTextSharp.text.Color.BLACK;
    table.AddCell(c);