[#12611] - Substring disabling full-string to print on nextline

Category:
Bug report
Priority:
High
Status:
Feedback Requested
Project: Severity:
Critical
Resolution:
Open
Component: Reproducibility:
Always
Assigned to:
0

We have 2 string of same size, one string is getting printed completely and other one is getting split(last word of string is not printing).

working : CNIP OFFSETAUG23TEST01 - JA8NM1811QVX1AGI - XXXXXXX.XXX XXXXXXXXX X-XXXXXXXX - PAYMNT1PAYMNT2PAY

not working : CNIP OFFSETAUG22TEST02 - JA8ME5718GIV1AXF - XXXXXXX.XXX XXXXXXXXX X-XXXXXXXX - PAYMNT1PAYMNT2PAY

We have tested PDF with few scenarios it seems like jasper is not handling "isStretchWithOverflow" attribute properly when string "- JA8ME5718GIV1AXF -" includes V<any number> with string size more then 92.

eg-: "- JA8NMIV11811QVX1 -", "- JA8NMV11811QVX1 - "," - JA8NMV21811QVX1 -"

string is not working with mentioned eg substrings.

snippet of jrxml is below-:

<textField isStretchWithOverflow="true">
<reportElement positionType="Float" x="250" y="30" width="300" height="20" uuid="404be7ac-1754-4b79-8000-c2a45d6824c3">
<printWhenExpression><![CDATA[$F{AVALTY}!=null]]></printWhenExpression>
</reportElement>
<textElement textAlignment="Left"/>
<textFieldExpression><![CDATA[$F{AVALTY}]]></textFieldExpression>
</textField>

v6.0.0
atulnamdeo7's picture
Joined: Feb 26 2020 - 11:05pm
Last seen: 4 weeks 1 day ago

1 Comment:

#1
  • Status:New» Feedback Requested
  • Assigned:nobody» teodord

Hi,

The problem comes from the fact that you are not specifying any font for your text fields. So a default font is used, both when the text size is calculated at report fill time and then when the text is actually rendered in PDF.
The problem is that AWT and PDF have different fonts as defaults, with different metrics. So while the text might fit when filling the report (AWT calculations), it does not fit in PDF, where the default font is slightly larger.

The solution is to make sure the exact same font is used by Java/AWT at report fill time and then embedded into the PDF at export time.
This can be done with font extensions, which can be created with Jaspersoft Studio.

The easiest to fix this is to use one of the DejaVu fonts that we ship with the jasperreports-fonts-x.x.x.jar and which is available in all Jaspersoft products, including JSS and JRS.
If you embed the library in your own Java application, just make sure this JAR is added to the classpath.

I hope this helps.
Teodor

Feedback