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.
Click on the particular textfield in iReport. On the right side, see TextField properties. Check the option "STRETCH WITH OVERFLOW".
The stretchType attribute of a report element can be used to customize the stretch behavior of the element when the enclosing report section stretches itself according to the text fields which stretch themselves.
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"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With