0
votes

I have the following Jasper Report subreport .jrxml file and it's producing very strange results.

Each row of data returned gets mysteriously split into 2 separate lines on the report. Specifically, the very last character in location_name appears on a new line (unless there's a comma in the data, in which case a new line starts there). Why does that happen?

<?xml version="1.0" encoding="UTF-8"?>    
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports 
    http://jasperreports.sourceforge.net/xsd/jasperreport.xsd">

    <queryString>
        <![CDATA[SELECT substr(location_name, 1, 5) as location_name from location]]>
    </queryString>

    <field name="location_name" class="java.lang.String"/>

    <detail>        
        <band height="25">
            <textField>
                <reportElement x="0" y="0" width="100" height="25"/>

                <box topPadding="1"><topPen lineWidth="0.5"/></box>

                <textElement>    
                    <font fontName="Times New Roman" size="8" 
                     isBold="true" pdfFontName="Helvetica-Bold"/>
                </textElement>

                <textFieldExpression class="java.lang.String">
                    <![CDATA[$F{location_name}]]>
                </textFieldExpression>
            </textField>
        </band>
    </detail>    
</jasperReport>

One possible clue is that when I opened this in Jaspersoft Studio I got a warning, "The use of pdf font is deprecated and replaced by the font extension". So I tried removing fontName and pdfFontName, leaving textElement as just:

                ...
                <textElement>
                    <font size="8" isBold="true" />
                </textElement>
                ...

That helps in that each line of data now appears on a single line, but the isBold has no effect.

Barring a solution, does anyone have a sample of how to bold text in a Jasper report?

1

1 Answers

0
votes

I resolved this by upgrading from jasperreports-4.0.2.jar to jasperreports-5.1.0.jar.