导出时,Jasper Reports字体大小始终为10

时间:2015-10-01 20:48:01

标签: java jasper-reports

我正在尝试在报告中使用不同的字体大小。在Jaspersoft Studio中,它显示具有正确字体大小的文本,但是当我使用Java软件导出为PDF时,整个报告的字体大小为10。

我尝试了很多不同的字体,但是得到了相同的输出。 我正在使用jasperreports-5.6.1。

我将以下jar包含在类路径中:

  • 的JasperReports-5.6.1.jar
  • 的JasperReports-图表主题-5.6.1.jar
  • 的JasperReports的字体-5.6.1.jar
  • JasperReports的函数-5.6.1.jar

我尝试使用我的Java程序导出到H​​tml,但它无效。它假定任何导出格式的字体大小为10。我试图使用很多字体大小。

这是我的jrxml:

<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 5.6.2.final using JasperReports Library version 5.6.1  -->
<!-- 2015-09-29T14:58:11 -->
<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="fnc_venda_delivery_por_cliente_detalhado" pageWidth="595" pageHeight="842" columnWidth="595" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0" uuid="1da45d48-333d-4496-ba82-e39cc4ea3ae7">
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="One Empty Record"/>
<property name="com.jaspersoft.studio.unit." value="pixel"/>
<parameter name="dataInicial" class="java.util.Date"/>
<parameter name="dataFinal" class="java.util.Date"/>
<parameter name="nomeSistema" class="java.lang.String"/>
<parameter name="nomeRelatorio" class="java.lang.String"/>
<parameter name="nomeEmpresa" class="java.lang.String"/>
<parameter name="nomeUsuario" class="java.lang.String"/>
<queryString>
    <![CDATA[]]>
</queryString>
<field name="vendaData" class="java.util.Date"/>
<field name="numeroDocumentoVenda" class="java.lang.String"/>
<field name="numeroSerieSat" class="java.lang.String"/>
<field name="empresaDescricao" class="java.lang.String"/>
<field name="terminalPdv.descricao" class="java.lang.String"/>
<field name="parcelaNumero" class="java.lang.Integer"/>
<field name="parcelaValor" class="java.math.BigDecimal"/>
<field name="pagamentoData" class="java.util.Date"/>
<field name="pagamentoValor" class="java.math.BigDecimal"/>
<field name="pagamentoJuros" class="java.math.BigDecimal"/>
<field name="pagamentoDesconto" class="java.math.BigDecimal"/>
<background>
    <band splitType="Stretch"/>
</background>
<title>
    <band splitType="Stretch">
        <property name="com.jaspersoft.studio.unit.height" value="pixel"/>
    </band>
</title>
<pageHeader>
    <band splitType="Stretch">
        <property name="com.jaspersoft.studio.unit.height" value="pixel"/>
    </band>
</pageHeader>
<columnHeader>
    <band height="15" splitType="Stretch">
        <property name="com.jaspersoft.studio.unit.height" value="pixel"/>
        <staticText>
            <reportElement x="1" y="0" width="54" height="15" uuid="fd3d2c8d-07ef-4cfd-a62d-7b2fbe9f4dca">
                <property name="com.jaspersoft.studio.unit.height" value="pixel"/>
            </reportElement>
            <textElement>
                <font fontName="UbuntuMonoFont" size="7" isBold="true"/>
            </textElement>
            <text><![CDATA[Data Venda]]></text>
        </staticText>
        <staticText>
            <reportElement x="58" y="0" width="30" height="15" uuid="1a2e14de-be90-4a0c-8b44-dff30061a059"/>
            <textElement>
                <font fontName="UbuntuMonoFont" size="7" isBold="true"/>
            </textElement>
            <text><![CDATA[Cupom]]></text>
        </staticText>
        <staticText>
            <reportElement x="110" y="0" width="44" height="15" uuid="f6f31d52-0b69-47f2-8eeb-d7585d45d514"/>
            <textElement>
                <font fontName="UbuntuMonoFont" size="7" isBold="true"/>
            </textElement>
            <text><![CDATA[SAT]]></text>
        </staticText>
        <staticText>
            <reportElement x="263" y="0" width="58" height="15" uuid="126d1c6d-ae28-4538-9fb2-5b65c45bcf5c"/>
            <textElement>
                <font fontName="UbuntuMonoFont" size="7" isBold="true"/>
            </textElement>
            <text><![CDATA[Terminal]]></text>
        </staticText>
        <staticText>
            <reportElement x="370" y="0" width="40" height="15" uuid="cf4976c9-a1b8-4b7b-9369-6996da1b990b"/>
            <textElement>
                <font fontName="UbuntuMonoFont" size="7" isBold="true"/>
            </textElement>
            <text><![CDATA[Data Pgto]]></text>
        </staticText>
        <staticText>
            <reportElement x="325" y="0" width="42" height="15" uuid="30add7e7-08ea-45f0-8c28-a19cc225df1f"/>
            <textElement textAlignment="Right">
                <font fontName="UbuntuMonoFont" size="7" isBold="true"/>
            </textElement>
            <text><![CDATA[Valor]]></text>
        </staticText>
        <staticText>
            <reportElement x="90" y="0" width="15" height="15" uuid="c0c6fbdf-f881-4c6d-936b-e40929549143">
                <property name="com.jaspersoft.studio.unit.width" value="pixel"/>
            </reportElement>
            <textElement textAlignment="Left">
                <font fontName="UbuntuMonoFont" size="7" isBold="true"/>
            </textElement>
            <text><![CDATA[P]]></text>
        </staticText>
        <staticText>
            <reportElement x="155" y="0" width="70" height="15" uuid="526bf8cc-9aea-4cb4-b719-4c12c764c87e"/>
            <textElement>
                <font fontName="UbuntuMonoFont" size="7" isBold="true"/>
            </textElement>
            <text><![CDATA[Empresa]]></text>
        </staticText>
        <staticText>
            <reportElement x="410" y="0" width="59" height="15" uuid="e2b262ed-bb0a-454a-b601-76e796b2601e"/>
            <textElement textAlignment="Right">
                <font fontName="UbuntuMonoFont" size="7" isBold="true"/>
            </textElement>
            <text><![CDATA[Valor Pgto]]></text>
        </staticText>
        <staticText>
            <reportElement x="472" y="0" width="40" height="15" uuid="e1ab4731-fcb3-4b0c-858e-6e536125bdda"/>
            <textElement textAlignment="Right">
                <font fontName="UbuntuMonoFont" size="7" isBold="true"/>
            </textElement>
            <text><![CDATA[Juros]]></text>
        </staticText>
        <staticText>
            <reportElement x="515" y="0" width="40" height="15" uuid="a14801b3-e7c7-4e87-a700-d1d877ffef55"/>
            <textElement textAlignment="Right">
                <font fontName="UbuntuMonoFont" size="7" isBold="true"/>
            </textElement>
            <text><![CDATA[Desconto]]></text>
        </staticText>
    </band>
</columnHeader>
<detail>
    <band height="31" splitType="Stretch">
        <property name="com.jaspersoft.studio.unit.height" value="pixel"/>
        <textField pattern="dd/MM/yy HH:mm" isBlankWhenNull="true">
            <reportElement style="TesteFont6" x="1" y="1" width="55" height="30" uuid="fe73298a-11e2-458b-ba1f-a50d3cbc2dc8">
                <property name="com.jaspersoft.studio.unit.width" value="pixel"/>
                <property name="com.jaspersoft.studio.unit.y" value="pixel"/>
            </reportElement>
            <textElement>
                <font fontName="Times New Roman" size="6"/>
            </textElement>
            <textFieldExpression><![CDATA[$F{vendaData}]]></textFieldExpression>
        </textField>
        <textField isBlankWhenNull="true">
            <reportElement style="TesteFont6" x="58" y="1" width="30" height="30" uuid="b94362ef-8ab9-4147-8c70-1dc340afcebc">
                <property name="com.jaspersoft.studio.unit.width" value="pixel"/>
            </reportElement>
            <textElement>
                <font fontName="Times New Roman" size="6"/>
            </textElement>
            <textFieldExpression><![CDATA[$F{numeroDocumentoVenda}]]></textFieldExpression>
        </textField>
        <textField isBlankWhenNull="true">
            <reportElement style="TesteFont6" x="110" y="1" width="43" height="30" uuid="22009fa5-77a0-4d3c-a14b-c8bdc0762eee">
                <property name="com.jaspersoft.studio.unit.width" value="pixel"/>
            </reportElement>
            <textElement>
                <font fontName="Times New Roman" size="6"/>
            </textElement>
            <textFieldExpression><![CDATA[$F{numeroSerieSat}]]></textFieldExpression>
        </textField>
        <textField isBlankWhenNull="true">
            <reportElement x="263" y="1" width="59" height="30" uuid="954772cb-f737-49e0-a70c-7aa8e60337f5">
                <property name="com.jaspersoft.studio.unit.width" value="pixel"/>
            </reportElement>
            <textElement>
                <font fontName="Times New Roman" size="6"/>
            </textElement>
            <textFieldExpression><![CDATA[$F{terminalPdv.descricao}]]></textFieldExpression>
        </textField>
        <textField isBlankWhenNull="true">
            <reportElement x="155" y="1" width="105" height="30" uuid="302c9609-68db-47c7-bc4d-456aa1c6da8b">
                <property name="com.jaspersoft.studio.unit.width" value="pixel"/>
            </reportElement>
            <textElement>
                <font fontName="Times New Roman" size="6"/>
            </textElement>
            <textFieldExpression><![CDATA[$F{empresaDescricao}]]></textFieldExpression>
        </textField>
        <textField isBlankWhenNull="true">
            <reportElement style="TesteFont6" x="90" y="1" width="15" height="30" uuid="ed5d0d92-214b-4955-9198-0f2a4a49a062">
                <property name="com.jaspersoft.studio.unit.width" value="pixel"/>
            </reportElement>
            <textElement textAlignment="Left">
                <font fontName="Times New Roman" size="6"/>
            </textElement>
            <textFieldExpression><![CDATA[$F{parcelaNumero}]]></textFieldExpression>
        </textField>
        <textField pattern="dd/MM/yy HH:mm" isBlankWhenNull="true">
            <reportElement x="370" y="1" width="55" height="30" uuid="4b4b93d9-1b83-4f04-8d07-10ddcd10e394">
                <property name="com.jaspersoft.studio.unit.width" value="pixel"/>
            </reportElement>
            <textElement>
                <font fontName="Times New Roman" size="6"/>
            </textElement>
            <textFieldExpression><![CDATA[$F{pagamentoData}]]></textFieldExpression>
        </textField>
        <textField pattern="#,##0.00" isBlankWhenNull="true">
            <reportElement x="325" y="1" width="42" height="30" uuid="8345515e-e50d-4820-aa56-fdfa0a789be7">
                <property name="com.jaspersoft.studio.unit.width" value="pixel"/>
            </reportElement>
            <textElement textAlignment="Right">
                <font fontName="Times New Roman" size="6"/>
            </textElement>
            <textFieldExpression><![CDATA[$F{parcelaValor}]]></textFieldExpression>
        </textField>
        <textField pattern="#,##0.00" isBlankWhenNull="true">
            <reportElement x="429" y="1" width="40" height="30" uuid="b07508eb-be76-44ec-b14a-5cc93d09358f">
                <property name="com.jaspersoft.studio.unit.width" value="pixel"/>
            </reportElement>
            <textElement textAlignment="Right">
                <font fontName="Times New Roman" size="6"/>
            </textElement>
            <textFieldExpression><![CDATA[$F{pagamentoValor}]]></textFieldExpression>
        </textField>
        <textField pattern="#,##0.00" isBlankWhenNull="true">
            <reportElement x="472" y="1" width="40" height="30" uuid="eb747941-b01d-4c15-8ab8-61765c15cd37">
                <property name="com.jaspersoft.studio.unit.width" value="pixel"/>
            </reportElement>
            <textElement textAlignment="Right">
                <font fontName="Times New Roman" size="6"/>
            </textElement>
            <textFieldExpression><![CDATA[$F{pagamentoJuros}]]></textFieldExpression>
        </textField>
        <textField pattern="#,##0.00" isBlankWhenNull="true">
            <reportElement x="515" y="1" width="40" height="30" uuid="5c195c3d-8bbe-4f96-8a6c-7f891339a508">
                <property name="com.jaspersoft.studio.unit.width" value="pixel"/>
            </reportElement>
            <textElement textAlignment="Right">
                <font fontName="Times New Roman" size="6"/>
            </textElement>
            <textFieldExpression><![CDATA[$F{pagamentoDesconto}]]></textFieldExpression>
        </textField>
    </band>
</detail>
<columnFooter>
    <band splitType="Stretch">
        <property name="com.jaspersoft.studio.unit.height" value="pixel"/>
    </band>
</columnFooter>
<pageFooter>
    <band splitType="Stretch">
        <property name="com.jaspersoft.studio.unit.height" value="pixel"/>
    </band>
</pageFooter>
<summary>
    <band splitType="Stretch">
        <property name="com.jaspersoft.studio.unit.height" value="pixel"/>
    </band>
</summary>

2 个答案:

答案 0 :(得分:0)

我在Google上发现了这篇文章:http://community.jaspersoft.com/questions/826303/font-size-tomcat-pdf-generation

它解决了我的问题,但我不喜欢在我的应用程序中编译报表的想法。 Jaspersoft Studio应该以正确的方式编译它。

在填写报告之前,我必须在我的java程序中编译我的jxml文件以生成.jasper文件:

status <- tryCatch(
    getURL(URL, ssl.verifypeer=FALSE, useragent="R"),
    error = function(e) e
)

if(inherits(status,  "error")) next

如果有人在不编译java代码中的jrxml的情况下解决了这个问题,请告诉我,我会将其标记为正确答案。

答案 1 :(得分:0)

我也碰巧发生过,但我只是使用相同的原始版本jrxml文件进行编译并正常工作...

在我的程序jasperreport 5.1上安装之前,但我开始使用ireport的5.6版本进行编译。.这不起作用...

所以最后我使用5.1版本并编译并运行良好