Table.GetHeight() Not Working

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)

    Row hdRow = table.Rows.Add();
    hdRow.BackgroundColor = Color.LightBlue;
    var hdCell = hdRow.Cells.Add();
    hdCell.Paragraphs.Add(new TextFragment("TABLE HEADER"));

    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()));



    doc.Save(path, SaveFormat.Pdf);



Thank you for contacting support.

We have worked with the data shared by you and have been able to reproduce the issue in our environment. A ticket with ID PDFNET-45386 has been logged in our issue management system for further investigation and resolution. The ticket ID has been linked with this thread so that you will receive notification as soon as the ticket is resolved.

We are sorry for the inconvenience.

Specifying Top before calling GetHeight() breaks it. It works if you call GetHeight() and THEN set the top property.

Is there a way to get a row’s height before adding it to the document?


Thank you for getting back to us.

We have recorded your findings about Top property causing the issue with height of the Table. This will help us investigate and resolve the ticket. Moreover, we are afraid you may not get height of a row, unless specified explicitly as row.FixedRowHeight = 50;. Otherwise the height is returned as zero and is probably set at the time document is saved.

We hope this will clarify any ambiguity. Please feel free to contact us if you need any further assistance.