Skip to main content
Skip table of contents

How do setMinimumSize() and setFixedSize() interact?

Is it OK to call setMinimumSize(15) on some cells in a row, and setFixedSize(15) on the other cells of the same row?

What I would like is for iText to increase the row height to accommodate the text in the cells whose minimum height is set, while letting text in cells set to a fixed height clip. Is that what iText does?

If not, how do I achieve this? While we're at it, am I correct that calling neither setMinimumSize() nor setFixedSize() is equivalent to calling setMinimumSize(0), meaning that iText makes the cell as tall as it needs to be to accommodate the text?

Posted on StackOverflow on Feb 28, 2014 by Kartick Vaddadi

The value defined using setFixedHeight() always gets preference. If you use setMinimumHeight() and setFixedHeight() in the same row, and you define a minimum height along with a fixed height, the fixed height prevails.

  • if the minimum height is set to 30pt and the fixed height is 60pt, the height will be 60pt, no matter how much content is added to the cell.

  • if the minimum height is set to 60pt and the fixed height is 60pt, the height will be 60pt, no matter how much content is added to the cell.

  • if the minimum height is set to 120pt and the fixed height is 60pt, the height will be 60pt, no matter how much content is added to the cell.

If different fixed heights are defined, the highest value is taken. For instance: if you have a row where one cell has a fixed height (e.g 120 pt) that is higher than the fixed height of another cell (e.g. 60 pt), then the highest value (in this case 120) prevails.

All of this is demonstrated in the FixedHeightCell example. Please take a look at the resulting PDF. In row D all the cells have a fixed height of 60 pt. In row E, most cells also have a fixed height of 60, but the cell in column 4 has a fixed height of 120, hence the height of the row is 120. Then there's row F, with a fixed height of 60 pt and a minimum height of 120 pt. Although we add text that doesn't fit the cell in column 2, the content is truncated.

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.