2

There are some related questions about this topic in SO but without a solution (the closest one here)

I have a long text as input for a text field in a jasper report, if the page breaks a part of the text is getting truncated if the split text has a bold text. If the split text is just plain, it works fine.

It seems like JasperReports engine can't calculate the max number of characters in a page if the input text has a bold html tag and then it cuts the leftover words at export to PDF. I'm using JasperReports 6.2.0

This is the source code:

<band height="40" splitType="Stretch">
    <textField isStretchWithOverflow="true" isBlankWhenNull="true">
        <reportElement positionType="Float" stretchType="RelativeToBandHeight" x="30" y="10" width="510" height="20" isPrintWhenDetailOverflows="true">
            <property name="local_mesure_unity" value="pixel"/>
            <property name="com.jaspersoft.studio.unit.y" value="px"/>
            <property name="local_mesure_unitx" value="pixel"/>
            <property name="com.jaspersoft.studio.unit.x" value="px"/>
            <property name="local_mesure_unitwidth" value="pixel"/>
            <property name="com.jaspersoft.studio.unit.width" value="px"/>
            <property name="local_mesure_unitheight" value="pixel"/>
            <printWhenExpression><![CDATA[$P{myInputData} != null]]></printWhenExpression>
        </reportElement>
        <textElement textAlignment="Justified" markup="html">
            <font fontName="ArialExtendedJasper"/>
        </textElement>
        <textFieldExpression><![CDATA[$P{myInputData}]]></textFieldExpression>
    </textField>
</band>

EDIT: Added font extension properties

<?xml version="1.0" encoding="UTF-8"?>
<fontFamilies>
  <fontFamily name="ArialExtendedJasper">
    <normal>fonts/ArialExtendedJasper/arial.ttf</normal>
    <bold>fonts/ArialExtendedJasper/arialbd.ttf</bold>
    <italic>fonts/ArialExtendedJasper/ariali.ttf</italic>
    <boldItalic>fonts/ArialExtendedJasper/arialbi.ttf</boldItalic>
    <pdfEncoding>Identity-H</pdfEncoding>
    <pdfEmbedded>true</pdfEmbedded>
    <exportFonts>
    </exportFonts>
  </fontFamily>
</fontFamilies>
Jesus Peralta
  • 661
  • 1
  • 8
  • 18
  • 1
    Did you try different fonts? Are you using font extensions? – Alex K May 31 '17 at 11:01
  • Did you try to remove markup? – Alex K May 31 '17 at 19:05
  • 1
    If I would guess this is a typical [font extensions](https://stackoverflow.com/documentation/jasper-reports/5773/font-extensions) problem. – Petter Friberg May 31 '17 at 20:44
  • Hi @AlexK, I'm using font extensions and I test it with other fonts but the error is difficult to reproduce with its because the text size is bigger or smaller depending the font and it moves everything in the page. Otherwise I need to work with the Arial extended font because of project requirement. – Jesus Peralta Jun 01 '17 at 06:58

1 Answers1

0

Alex and Petter were right, it was a font extension problem, I changed the fonts (source .ttf files) and this problem didn't happen again.

I downloaded the arial font from internet without knowing that this font is licensed and what you find there isn't reliable.

Now I'm using Google Fonts, they are free and works perfect!

Jesus Peralta
  • 661
  • 1
  • 8
  • 18