We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

table.GetHeight returns wrong result

Hello. Recently I have updated Aspose.Pdf library on few major versions to 22.4.0. And as I understand - now header renders inside top margin. So I need to calculate height of my pdf footer to set a correct margin, but I faced with issue with text wrapping in TextFrame inside table, so visually table height higher but table.GetHeight() returns the same result.

I prepared a small example to better understanding. This code renders document with two tables, one of them with short text, but another with long text that will be wrapped. And TextFrame with result of table.GetGeight().

            [Test]
		public void TableHeightTest()
		{
			AsposeLicenceProvider.InitPdfLicense();

			using var pdf = new Document();
			var page = pdf.Pages.Add();
			AddTable(page, false);
			AddTable(page, true);

			pdf.Save("tableHeightTest.pdf");
		}

		public void AddTable(Page page, bool useLongText)
		{
			var table = new global::Aspose.Pdf.Table
			{
				IsBroken = true,
				ColumnWidths = "50% 50%",
				RepeatingRowsCount = 2
			};

			var row = table.Rows.Add();
			var cell = row.Cells.Add();
			cell.Paragraphs.Add(new TextFragment("short text"));
			cell = row.Cells.Add();
			cell.Paragraphs.Add(new TextFragment("short text"));
			row = table.Rows.Add();
			cell = row.Cells.Add();
			var text = useLongText ? "very very very very very very very very long text" : "short text";
			cell.Paragraphs.Add(new TextFragment(text));
			cell = row.Cells.Add();
			cell.Paragraphs.Add(new TextFragment("short text"));
			row = table.Rows.Add();
			cell = row.Cells.Add();
			cell.Paragraphs.Add(new TextFragment("short text"));
			cell = row.Cells.Add();
			cell.Paragraphs.Add(new TextFragment("short text"));
			page.Paragraphs.Add(table);

			page.Paragraphs.Add(new TextFragment($"table.GetHeight() returns: {table.GetHeight()}"));
		}

As result I have tableHeightTest.pdf (2.1 KB)
document.

Hello Oleksii, A ticket with ID PDFNET-51736 has been created in our issue tracking system to further investigate the issue on our end. This thread has been linked with the issue so that you may be notified once the issue will be fixed.