Whenever I call GetHeight() on a table it returns some large number like 2147483116. How can I get the height of the table, or at least the height of a row so I can add them up?
TableGetHeightTest.pdf (2.4 KB)
public void TableGetHeightTest()
{
string methodName = MethodBase.GetCurrentMethod().Name;
string path = DocConfig.GetAssetOutputPath(methodName + ".pdf");
var doc = new Document();
Page page = doc.Pages.Add();
page.Paragraphs.Add(new TextFragment($"{methodName} created on {DateTime.Now}") {HorizontalAlignment = HorizontalAlignment.Center});
var table = new Table
{
Margin = new MarginInfo(0, 0, 0, 0),
ColumnWidths = "300",
DefaultCellPadding = new MarginInfo(5, 5, 5, 5),
DefaultCellTextState = {HorizontalAlignment = HorizontalAlignment.Left, ForegroundColor = Color.Black},
Top = 144,
Left = 72,
IsBordersIncluded = true,
DefaultCellBorder = new BorderInfo(BorderSide.All, .5f, Color.Gray)
};
//header
Row hdRow = table.Rows.Add();
hdRow.BackgroundColor = Color.LightBlue;
var hdCell = hdRow.Cells.Add();
hdCell.Paragraphs.Add(new TextFragment("TABLE HEADER"));
//rows
for (int r = 0; r < 20; r++)
{
var row = new Row();
var cell = new Cell();
cell.Paragraphs.Add(new TextFragment("previous table height: " + table.GetHeight()));
row.Cells.Add(cell);
table.Rows.Add(row);
}
page.Paragraphs.Add(table);
doc.Save(path, SaveFormat.Pdf);
doc.Dispose();
FileAssert.Exists(path);
}