Jasper Report在填充整个文本字段之前截断文本 [英] Jasper Report truncates text before filling the whole text field
问题描述
我的PDF报告出现问题,文本字段中的字符串在填充文本字段之前被截断。丢失字符的数量(5-6)不足以超过 textField
的结尾。
我将 text.truncate.at.char
属性添加到报表元素,但字符串仍然被截断(显示比以前更多的字符后。)
我还检查是否有其他报告元素阻止文本字段的结尾,但没有。
最后我尝试了一个潜力修复我找到并添加\ n到行的末尾,但这也没有帮助。
在iReport Designer中显示整个字符串。
PDF报告
iReport Designer预览
有谁知道如何让Jasper Reports使用文本字段中的整个空格?
PS:允许文本溢出到由于客户的意愿,下一行是不可能的。
我正在使用Jasper Reports 5.5.2。
编辑:
textField
是子报表中详细信息区域的一部分。我不允许共享整个.jrxml,但这是textField的代码:
< textField>
< reportElement style =Unicodemode =Opaquex =0y =2width =467height =17forecolor =#FFFFFFbackcolor =#00007Fuuid = e810d7a4-6802-4620-af2f-4c385a9e80a6 >
< property name =net.sf.jasperreports.text.truncate.at.charvalue =true/>
< / reportElement>
< textElement verticalAlignment =Middlemarkup =none>
< font size =10isBold =true/>
< / textElement>
< textFieldExpression><![CDATA [更多细节 - + $ F {描述} +(+ $ F {Id} +)]]>< / textFieldExpression>
< / textField>
描述的长度可变,Id是GUID。在这种情况下, textField
中仍应有足够的空间来显示整个GUID。
这是使用的另一个屏幕截图isStretchWithOverflow =true
:
并检查样式
和 textElement
<上的设置/ p>
OP已解决,如评论:
安装了字体扩展程序,删除 isBold =true
在 textElement
上,因为设置为 textElement
的样式有 isBold =false
I'm having a problem with my PDF report where a String in a text field is truncated before filling the text field. The amount of missing characters (5-6) would not be enough to go over the end of the textField
.
I added the text.truncate.at.char
property to the report element but the String is still truncated (after displaying some more characters than before).
I also checked if there are other report elements blocking the end of the text field, but there are none.
Lastly I tried a potential fix I found and added "\n" to the end of the line, but that also did not help.
In iReport Designer the whole String is displayed.
PDF report
iReport Designer Preview
Does anyone know how to make Jasper Reports use the whole space in the text field?
PS: Allowing the text to overflow to the next line is not possible due to customer wishes.
I'm using Jasper Reports 5.5.2.
Edit:
The textField
is part of a detail band in a subreport. I'm not allowed to share the whole .jrxml, but this is the code for the textField:
<textField>
<reportElement style="Unicode" mode="Opaque" x="0" y="2" width="467" height="17" forecolor="#FFFFFF" backcolor="#00007F" uuid="e810d7a4-6802-4620-af2f-4c385a9e80a6">
<property name="net.sf.jasperreports.text.truncate.at.char" value="true"/>
</reportElement>
<textElement verticalAlignment="Middle" markup="none">
<font size="10" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[" More Details - "+$F{Description} + " ("+$F{Id}+")"]]></textFieldExpression>
</textField>
The description is of variable length, the Id is a GUID. In this case there should still be more than enough space in the textField
to display the whole GUID.
Here is another screenshot with isStretchWithOverflow="true"
:
The text is now displayed completely in the first line but the textField
is larger which is not accepted by the customer.
Why is it different in pdf and iReport designer?
This is because iText (the library creating your pdf) is doing its "best effort" to render the font you have indicated in jrxml and its not good enough (it is using another font that is bigger...).
To avoid these problems you need to use font extensions and check your settings on style
and textElement
Checklist to rendered font correctly in pdf
How to add font extension using iReport
OP solved as in comment:
Font extension installed, removing isBold="true"
on textElement
, since the style set to textElement
had isBold="false"
这篇关于Jasper Report在填充整个文本字段之前截断文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!