itext - setMinimumSize()和setFixedSize()如何交互? [英] itext -- How do setMinimumSize() and setFixedSize() interact?

查看:238
本文介绍了itext - setMinimumSize()和setFixedSize()如何交互?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在iText中是否定义好在一行中的某些单元格上调用setMinimumSize(15),在同一行的其他单元格上调用setFixedSize(15)?

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?

我想要的是iText增加行高以容纳设置了最小高度的单元格中的文本,同时让单元格中的文本设置为固定高度剪辑。这是iText的作用吗?

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.

虽然我们正在使用它,但我是正确的,调用setMinimumSize()和setFixedSize()都不等同于调用setMinimumSize(0) - iText使得单元格需要容纳文本吗?

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?

这是iText 2.1.6。

This is with iText 2.1.6.

推荐答案

我已经在评论中解释过 setFixedHeight()总是得到偏好。如果在同一行中使用 setMinimumHeight() setFixedHeight(),则定义最小高度以及固定高度,固定高度为准。

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.


  • 如果最小高度设置为30pt且固定高度为60pt,则高度为60pt ,无论在单元格中添加多少内容。

  • 如果最小高度设置为60pt且固定高度为60pt,则高度为60pt,无论内容多少添加到单元格。

  • 如果最小高度设置为120pt且固定高度为60pt,则无论向单元格添加多少内容,高度都将为60pt。

如果定义了不同的固定高度,则采用最高值。例如:如果您有一行,其中一个单元格具有固定高度(例如120磅)高于另一个单元格的固定高度(例如60磅),则最高值(在本例中为120)占优势。

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.

你声称在我写的书中没有提到这一点。请注意,这本书约有600页。我写的很多文字都是由出版商编辑的。否则这本书将会有一千多页。

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.

您可以写一个小的测试示例,例如 FixedHeightCell 示例。请查看生成的PDF 。在行D中,所有单元具有60磅的固定高度。在E行中,大多数单元格的固定高度也为60,但第4列中的单元格固定高度为120,因此行的高度为120.然后是F行,固定高度为60 pt,最小高度120磅。虽然我们添加的文本不适合第2列中的单元格,但内容会被截断。

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.

这篇关于itext - setMinimumSize()和setFixedSize()如何交互?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆