Reputation: 33
I'm having a problem in a report where I have a $F{field}
in which you can receive a value with whitespaces at the end. Example :
"20142101 ").
The textField must be horizontally align to "right".
The result in my PDF is "20142101" (the whitespaces doesn't appear)
The problem (I think) is that JasperReports automatically does a trim in the textField but I don't want this!
I've tried using options:
but it doesn't work...
Any suggestions?
Upvotes: 2
Views: 4594
Reputation: 754
You can use a borderless box with right/left padding for the textfields.
<textField>
<reportElement ../>
<box border="None" rightPadding="10"/>
<textElement textAlignment="Right"/>
<textFieldExpression..
Note, when I tried it out, my jasper studio editor turned the box element into the following but it has the same effect.
<textField>
<reportElement mode="Opaque" x="233" y="0" width="303" height="18" forecolor="#FFFFFF" backcolor="#817F82" uuid="501dc3cf-f3cf-45d4-aa25-de24c4100354"/>
<box rightPadding="5">
<pen lineWidth="0.0" lineStyle="Solid"/>
</box>
<textElement textAlignment="Right" verticalAlignment="Middle">
<font fontName="Arial" size="10" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA["My data where I want blank spaces in the end of this sentence. "]]></textFieldExpression>
</textField>
Upvotes: 2
Reputation: 33
Thank you for your help !
I've found a solution which works but it's not very appropriate...
(My $F{field} is always a string of 60 characters)
($F{field} != null && $F{field}.length() == 60 && $F{field}.substring(59).equals(" ")) ? "<pre>"+$F{field}.substring(0,59)+" </pre>" : $F{field}
(with markup html)
I will test with \t too.
Thx
Upvotes: 0