我想将TableCell中的文本对齐以与单元格的底部对齐。我没有在tablecell属性中的任何位置看到此选项。以下是构建该表的代码片段。
Table thirdTable = section.Headers.Primary.AddTable();
thirdTable.Format.Font.Size = "7pt";
column = thirdTable.AddColumn("1.5cm");
column.Format.Alignment = ParagraphAlignment.Center;
column = thirdTable.AddColumn("1cm");
column.Format.Alignment = ParagraphAlignment.Center;
column = thirdTable.AddColumn("7cm");
column.Format.Alignment = ParagraphAlignment.Left;
column = thirdTable.AddColumn("2.5cm");
column.Format.Alignment = ParagraphAlignment.Center;
column = thirdTable.AddColumn("1cm");
column.Format.Alignment = ParagraphAlignment.Center;
column = thirdTable.AddColumn("1.5cm");
column.Format.Alignment = ParagraphAlignment.Center;
column = thirdTable.AddColumn("1.5cm");
column.Format.Alignment = ParagraphAlignment.Center;
row = thirdTable.AddRow();
row = thirdTable.AddRow();
row.Cells[0].AddParagraph("Segment Code");
row.Cells[1].AddParagraph("Milepoint");
row.Cells[2].AddParagraph("Description of Milepoint");
row.Cells[3].AddParagraph("City Name");
row.Cells[4].AddParagraph("Segment Code");
row.Cells[5].AddParagraph("Milepoint");
row.Cells[6].AddParagraph("FA Route Number");
答案 0 :(得分:4)
好吧,我终于找到了它,这一直是我脸上的面孔。我错过了它。
此示例文档http://www.pdfsharp.net/wiki/Invoice-sample.ashx中介绍了该内容。
这就是我的代码现在的样子
row.Cells[0].AddParagraph("Segment Code");
row.Cells[0].VerticalAlignment = VerticalAlignment.Bottom;
row.Cells[1].AddParagraph("Milepoint");
row.Cells[1].VerticalAlignment = VerticalAlignment.Bottom;
row.Cells[2].AddParagraph("Description of Milepoint");
row.Cells[2].VerticalAlignment = VerticalAlignment.Bottom;
row.Cells[3].AddParagraph("City Name");
row.Cells[3].VerticalAlignment = VerticalAlignment.Bottom;
row.Cells[4].AddParagraph("Segment Code");
row.Cells[4].VerticalAlignment = VerticalAlignment.Bottom;
row.Cells[5].AddParagraph("Milepoint");
row.Cells[5].VerticalAlignment = VerticalAlignment.Bottom;
row.Cells[6].AddParagraph("FA Route Number");
row.Cells[6].VerticalAlignment = VerticalAlignment.Bottom;
答案 1 :(得分:1)
您只需要添加此行一次:
row.VerticalAlignment = VerticalAlignment.Bottom;
无需对每个单元格进行操作。