我试图从jrxml生成一个Rtf。 当我生成pdv everithing工作正常,但当我尝试将其导出到rtf时,文本就会消失。 我只用一个文本框尝试了jrxml的简化版本,但我仍然遇到同样的问题。我错过了一些特殊的参数?
这是我的测试JRXML:
<?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" name="report name" pageWidth="595" pageHeight="842" columnWidth="535" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20">
<property name="ireport.zoom" value="1.0" />
<property name="ireport.x" value="0" />
<property name="ireport.y" value="0" />
<background>
<band splitType="Stretch" />
</background>
<title>
<band height="79" splitType="Stretch">
<staticText>
<reportElement x="0" y="0" width="555" height="79" />
<textElement />
<text><![CDATA[TEST]]></text>
</staticText>
</band>
</title>
<pageHeader>
<band height="35" splitType="Stretch" />
</pageHeader>
<columnHeader>
<band height="61" splitType="Stretch" />
</columnHeader>
<detail>
<band height="125" splitType="Stretch">
<textField>
<reportElement x="0" y="0" width="555" height="20" />
<textElement />
<textFieldExpression class="java.lang.String"><![CDATA["TEST"]]></textFieldExpression>
</textField>
</band>
</detail>
<columnFooter>
<band height="45" splitType="Stretch" />
</columnFooter>
<pageFooter>
<band height="54" splitType="Stretch" />
</pageFooter>
<summary>
<band height="42" splitType="Stretch" />
</summary>
</jasperReport>
[UPDATE]
这里是用于生成的代码:
JRRtfExporter exporter = new JRRtfExporter();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, baos);
exporter.exportReport();
ServletOutputStream ouputStream = resp.getOutputStream();
ouputStream.write(baos.toByteArray());
ouputStream.flush();
ouputStream.close();