3

I'd like to align the text in a TableCell to align to the bottom of the cell. I'm not seeing this option anywhere in the tablecell properties. Here is the snippet of code that builds that table.

        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");
Tyddlywink
  • 876
  • 7
  • 28

2 Answers2

7

Well I finally found it and it was infront of my face the entire time. I just missed it.

It is covered in this example doc http://www.pdfsharp.net/wiki/Invoice-sample.ashx.

This is what my code now looks like

        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;
Tyddlywink
  • 876
  • 7
  • 28
2

You just need to add this line once:

row.VerticalAlignment = VerticalAlignment.Bottom;

No need to do it for each cell.

Taian
  • 189
  • 8
  • 19