如何防止在Jasperreports中包装一行文本

时间:2021-09-01 22:19:04

I have a line of text which reads "International ID". But whenever I am to display in in my Jasperreport to PDF, it will sometimes be spread across two lines like this: "International ID". Is there a way to prevent wrapping in like in html I would use

我有一行文字写着“国际身份证”。但每当我在我的Jasperreport中显示PDF格式时,它有时会分散在两行中:“国际ID”。有没有办法防止像我将使用的HTML中的包装

<span style="white-space: nowrap">Long line with no breaks</span> 

1 个解决方案

#1


1  

Give sufficient width to the field "International ID" so that it won't wrap up in any exported format. Also check this with different languages (If you are supporting multiple languages).

为“国际ID”字段提供足够的宽度,以便它不会以任何导出的格式包装。另外用不同的语言检查(如果您支持多种语言)。

About the HTML text part, you can style textField elements using different markups like "Styled", "HTML", "RTF" etc. See Style a text field in JasperReports for details.

关于HTML文本部分,您可以使用不同的标记(如“Styled”,“HTML”,“RTF”等)设置textField元素的样式。有关详细信息,请参阅JasperReports中的样式文本字段。

However, HTML markup supports very basic HTML tags like <p>, <br>, <color> etc. It won't support style="white-space: nowrap".

但是,HTML标记支持非常基本的HTML标记,如

,
, 等。它不支持style =“white-space:nowrap”。

So you can either:

所以你可以:

  1. Increase the width of textField OR
  2. 增加textField OR的宽度

  3. Let the text cut-off by setting isStretchWithOverflow="false" (This is not recommended mostly)
  4. 通过设置isStretchWithOverflow =“false”(通常不推荐这个)让文本截止

#1


1  

Give sufficient width to the field "International ID" so that it won't wrap up in any exported format. Also check this with different languages (If you are supporting multiple languages).

为“国际ID”字段提供足够的宽度,以便它不会以任何导出的格式包装。另外用不同的语言检查(如果您支持多种语言)。

About the HTML text part, you can style textField elements using different markups like "Styled", "HTML", "RTF" etc. See Style a text field in JasperReports for details.

关于HTML文本部分,您可以使用不同的标记(如“Styled”,“HTML”,“RTF”等)设置textField元素的样式。有关详细信息,请参阅JasperReports中的样式文本字段。

However, HTML markup supports very basic HTML tags like <p>, <br>, <color> etc. It won't support style="white-space: nowrap".

但是,HTML标记支持非常基本的HTML标记,如

,
, 等。它不支持style =“white-space:nowrap”。

So you can either:

所以你可以:

  1. Increase the width of textField OR
  2. 增加textField OR的宽度

  3. Let the text cut-off by setting isStretchWithOverflow="false" (This is not recommended mostly)
  4. 通过设置isStretchWithOverflow =“false”(通常不推荐这个)让文本截止