0

Is it well-defined in iText 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? Thanks.

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

This is with iText 2.1.6.

Kartick Vaddadi
  • 4,818
  • 6
  • 39
  • 55
  • I read your book but I couldn't find where it talks of the case of using both setMinimumSize() and setFixedSize() TOGETHER in the same row. Can you tell me which page it's on? I can test anything for myself. If that's going to be your answer, it's not useful at all. – Kartick Vaddadi Feb 28 '14 at 14:44
  • I re-read that, and look a look at http://itextpdf.com/examples/iia.php?id=81 but they don't answer my question, and neither does your last comment. The question is what happens if different cells in the same ROW are set differently -- one has a fixed height of 15 and one has a minimum height of 15. – Kartick Vaddadi Feb 28 '14 at 14:59
  • In other words, once I call setFixedHeight(15) on one cell in a row, there's no point calling setMinimumHeight(15) on other cells in the row, since the latter are going to be ignored, anyway. Correct? – Kartick Vaddadi Feb 28 '14 at 15:03
  • Sure, I absolutely wouldn't ask you to fix an old version :) I did not claim that iText works differently. I just ask what the behavior is. Thanks for clarifying. – Kartick Vaddadi Feb 28 '14 at 15:20

1 Answers1

1

I already explained in a comment that 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.

You claim that this isn't mentioned in the book I wrote. Please note that the book counts about 600 pages. A lot of text I wrote was edited away by the publisher. Otherwise the book would have been a thousand pages and more.

You could have written a small test example, such as 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.

Bruno Lowagie
  • 75,994
  • 9
  • 109
  • 165
  • Part of this answer has been duplicated [here](http://stackoverflow.com/a/22115609/679449) – Kermit Mar 01 '14 at 15:58
  • Thanks, FreshPrinceofSO. -1 for this answer, though, because it does not answer the question asked -- what happens if I call setMinimumSize() and setFixedSize() with the SAME value on all cells in a row? Your answer talks about calling setMinimumSize() / setFixedSize() with DIFFERENT values for each cell in the row. It does give me useful information, but it doesn't answer the question asked. I could have written a test example for anything. Since you don't want to answer, please ignore my questions on SO henceforth. If someone else wants to answer, let them. If they don't, that's also fine. – Kartick Vaddadi Mar 03 '14 at 10:37
  • I don't see why the answer doesn't help you. It states: ´setFixedHeight()` always gets preference." A fortiori, the fixed height also prevails if the minimum height is equal to the fixed height. I'll update my answer so that it is more clear. – Bruno Lowagie Mar 03 '14 at 11:59