Search code examples
javahtmljasper-reports

Exporting Jasper report in HTML Format stretchType="ElementGroupHeight" is not working (When no spaces)


ITS WORKING FINE WITH PDF REPORTS BUT NOT WHEN I EXPORT JASPER CONTENT IN HTML REPORT

JASPER REPORT CODE----------------------------------------------------------------------

<textField isStretchWithOverflow="true" >
                    <reportElement key="" stretchType="ElementGroupHeight" x="406" y="0" width="132" height="20" forecolor="#050505" uuid="7717f0db-9ebe-4fef-9465-370d96121dc2"/>
                    <box padding="2">
                        <pen lineWidth="0.0"/>
                        <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                        <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                        <bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                        <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                    </box>
                    <textElement>
                        <font size="9"/>
                    </textElement>
                    <textFieldExpression><![CDATA[$F{days} != null?$F{days}+" day(s) ago" :"-"]]></textFieldExpression>
                </textField>

JAVA CODE -------------------------------------------------------------------------------

                    HtmlExporter exporter = new HtmlExporter();
                        exporter.setExporterOutput(new SimpleHtmlExporterOutput(out));
                        exporter.setExporterInput(new SimpleExporterInput(print));
                        exporter.exportReport();

--- HTML REPORT EMAIL IS NOT STRECHING TO HEIGHT --- HTML REPORT HERE EMAIL IS NOT STRECHING TO HEIGHT AS NO SPACES

--- PDF REPORT ITS WORKING FINE ---

[SEE HERE ITS WORKING FINE WITH PDF2


Solution

  • Set the net.sf.jasperreports.export.html.wrap.break.word property to true either globally in jasperreports.properties or in the report.

    Alternatively, you can set the net.sf.jasperreports.text.save.line.breaks property (globally or in the report, but can also be set at element level).