Paragraph Dimensions



I’m trying to create a nested table structure and I want the outer table cells width to match the dimensions of the inner tables (or whatever is in the cell).
I’m wondering if it would be possible to get the dimensions (width & height) of a rendered paragraph.

If it is too much work to make it work for any given type of paragraph, it would be nice to have at least the functions GetMinColumnWidth & GetMaxColumnWidth att the Cell level.




Dear Xavier,

Thank you for considering Aspose.

Getting the width and height of paragraph is not possible since the paragraph is rendered in the Save() method.

GetMinColumnWidth is supported, please refer to GettingMinimumColumnWidth. GetMaxColumnWidth is not supported yet. We can add support for it if necessary.


Thanks for your reply.

My problem with GetMinColumnWidth is that it is in the Table class and that you have to know which column the cell is in to get it’s width, which I don’t.
I’d like to have something like Cell::GetMinCellWidth().

Besides that, I think I found a bug with the Table::GetMinColumnWidth().
If you do something like this:

Table tableA = new Table();
Row rowA = tableA.Rows.Add();
Cell cellA = rowA.Cells.Add();

Table tableB = new Table();
Row rowB = tableB.Rows.Add();


You get ApplicationException: The column number is out of bound in GetMinColumnWidth method.
on the call to tableB.GetMinColumnWidth(0).


ps: What do you mean by GetMaxColumnWidth is not supported yet ?


Dear xbasty,

Thank you for considering Aspose.

1) You should not create a cell and add it into two tables, that will cause error.
2) I can provide a method to get the length of a string, I think this can help you to get the minimum of a cell. What is your idea?
3) I have made a mistake at the former post saying that GetMaxColumnWidth is not supported.


Dear Tommy,

A method to get the length (min & max) of a string would be fantastic, as long as it takes into account the associated TextInfo.

My idea is a bit difficult to explain. I need to convert HTML to pdf and it is very important to keep the layout of the tables intact. If you really need to know, I can try to explain but if you could just provides the 2 functions (GetMinWidth & GetMaxWidth) it would really save me a lot of work and make my program better (right now, I create a table each time I need to know the sizes of a text. While it seems to work, it’s a bit cumbersome and I haven’t tested it with different fonts and text formatting yet…)