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

Free Support Forum - aspose.com

Table Word Wrapping - Incorrect Height

I am building up a table within a PDF document consisting of user input. The page that the table resides on has other information that we need to insert. What this means is that we need to pre-empt page breaks and create a new page and a new table.

To do this I calculate the available space on a page, add a row to the table and then check the table height.

If the table height becomes greater than the page then I remove the row from the table, create a new page, new table and add the row to that.

This works fine when all the rows are a single line. The height calculations are accurate. Once a user begins to input longer text however and the cells begin to wrap text, the calculations begin to get in-accurate which leads to aspose automatically creating pages when saving the PDF. These auto created pages though are missing all the other information we insert onto a page.

How can I ensure that the table height is accurate even with word wrapping?

@dcoxall

Could you please share a working code sample that is able to replicate the exact issue that you are facing? We will test the scenario in our environment and address it accordingly.

In building an example to send you we identified the issue.

table.setColumnWidths("10% 20% 30% 40%");

Aspose doesn’t indicate any issue with the use of percentages BUT after setting the widths the table width is completely incorrect.

After calculating the pts myself and using that instead, all the issues went away.

So the root of the issue was in aspose not throwing an error when being given percentage widths instead of absolute widths.

@dcoxall

It is good to know that you are able to sort your issue out. The API also keeps margin values of the page into account while adding content in the PDF. It would be helpful if you can please share a minimal sample code snippet that can be used as reproducer of the issue. This way we will be able to investigate the reasons behind it and resolve it so that it would not occur next time.