JasperReport 不能导出中文字符

1. Situation背景

  • Springboot:2.6.4
  • jasperreports:6.20.0

2. Question问题

使用Jaspersoft Studio-6.20.0 设计报表模板本地预览正常,但是导出PDF的时候不显示中文字符。
正常应该是如下显示:![image.png](https://img-blog.csdnimg.cn/img_convert/fbaa6547d4c02fcb00ea2f3b892a92cf.png#clientId=ue19af1ed-c75b-4&crop=0&crop=0&crop=1&crop=1&from=paste&height=569&id=u8dd444ba&margin=[object Object]&name=image.png&originHeight=853&originWidth=1145&originalType=binary&ratio=1&rotation=0&showTitle=false&size=81641&status=done&style=none&taskId=u4aff4b8f-f051-4799-a58a-3948d8381c7&title=&width=763.3333333333334)
但是目前的结果是:
![image.png](https://img-blog.csdnimg.cn/img_convert/fb24798303e715870cba23218c89de7c.png#clientId=ue19af1ed-c75b-4&crop=0&crop=0&crop=1&crop=1&from=paste&height=573&id=u989670a4&margin=[object Object]&name=image.png&originHeight=859&originWidth=1153&originalType=binary&ratio=1&rotation=0&showTitle=false&size=38333&status=done&style=none&taskId=ud6b778e3-b3bc-46ec-80dc-449f914bf12&title=&width=768.6666666666666)

3. Answer解决方案

  1. 加载本地字体并且导出jar包

    后续模板设计器的字体名称 需要和 标签4 的一致。
    ![image.png](https://img-blog.csdnimg.cn/img_convert/23cc0be6c9f8fd64a4815053d194028b.png#clientId=ue19af1ed-c75b-4&crop=0&crop=0&crop=1&crop=1&from=paste&height=705&id=u6f04976a&margin=[object Object]&name=image.png&originHeight=1057&originWidth=1330&originalType=binary&ratio=1&rotation=0&showTitle=false&size=170781&status=done&style=none&taskId=u23cb0b84-3d1b-4021-911b-98a1cb07a4e&title=&width=886.6666666666666)

此处的字体可以直接使用本地环境如Win11在C:\Windows\Fonts路径下,当然也可以通过其他网站下载,如字客网

  1. 模板的字体使用上述字体名称

注意xml文件中的font fontName

<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.20.0.final using JasperReports Library version 6.20.0-2bc7ab61c56f459e8176eb05c7705e145cd400ad  -->
<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="contract_none" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="c1eeec34-e340-4152-82d1-741104a1b4bd">
    <property name="com.jaspersoft.studio.data.defaultdataadapter" value="One Empty Record"/>
    <style name="default" isDefault="true" isBlankWhenNull="true"/>
    <parameter name="contractCode" class="java.lang.String">
        <parameterDescription><![CDATA[合同编号]]></parameterDescription>
    </parameter>
    <parameter name="contractName" class="java.lang.String">
        <parameterDescription><![CDATA[合同名称]]></parameterDescription>
    </parameter>
    <parameter name="contractOriginalCode" class="java.lang.String">
        <parameterDescription><![CDATA[合同原始编号]]></parameterDescription>
    </parameter>
    <parameter name="originalCcyTaxIncludedAmt" class="java.math.BigDecimal">
        <parameterDescription><![CDATA[合同原币金额]]></parameterDescription>
    </parameter>
    <parameter name="localCcyTaxIncludedAmt" class="java.math.BigDecimal">
        <parameterDescription><![CDATA[合同本币金额]]></parameterDescription>
    </parameter>
    <parameter name="contractType" class="java.lang.String">
        <parameterDescription><![CDATA[合同类型]]></parameterDescription>
    </parameter>
    <parameter name="contractDetailType" class="java.lang.String">
        <parameterDescription><![CDATA[合同明细类型]]></parameterDescription>
    </parameter>
    <parameter name="supplierName" class="java.lang.String">
        <parameterDescription><![CDATA[供应商名称]]></parameterDescription>
    </parameter>
    <parameter name="operatorName" class="java.lang.String">
        <parameterDescription><![CDATA[经办人名称]]></parameterDescription>
    </parameter>
    <parameter name="operatorOrgName" class="java.lang.String">
        <parameterDescription><![CDATA[经办机构名称]]></parameterDescription>
    </parameter>
    <parameter name="operatorDeptName" class="java.lang.String">
        <parameterDescription><![CDATA[经办部门名称]]></parameterDescription>
    </parameter>
    <parameter name="effectiveDate" class="java.util.Date">
        <parameterDescription><![CDATA[合同生效日期]]></parameterDescription>
    </parameter>
    <parameter name="expiredDate" class="java.util.Date">
        <parameterDescription><![CDATA[合同到期日]]></parameterDescription>
    </parameter>
    <queryString>
        <![CDATA[]]>
    </queryString>
    <background>
        <band splitType="Stretch"/>
    </background>
    <title>
        <band height="100" splitType="Stretch">
            <staticText>
                <reportElement x="150" y="0" width="100" height="100" uuid="bf0eca6a-bbe2-4428-9c12-bb5188fd1a28">
                    <property name="com.jaspersoft.studio.unit.x" value="px"/>
                    <property name="com.jaspersoft.studio.unit.y" value="px"/>
                    <property name="com.jaspersoft.studio.unit.height" value="px"/>
                    <property name="com.jaspersoft.studio.unit.width" value="px"/>
                </reportElement>
                <box>
                    <topPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                    <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                    <bottomPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                    <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                </box>
                <textElement textAlignment="Left" verticalAlignment="Middle">
                    <font fontName="华文宋体" size="16"/>
                </textElement>
                <text><![CDATA[合同名称:]]></text>
            </staticText>
            <textField>
                <reportElement x="250" y="0" width="300" height="100" uuid="a1cda531-2fbe-45b0-9712-3eabb6d9e27f">
                    <property name="com.jaspersoft.studio.unit.x" value="px"/>
                    <property name="com.jaspersoft.studio.unit.y" value="px"/>
                    <property name="com.jaspersoft.studio.unit.width" value="px"/>
                    <property name="com.jaspersoft.studio.unit.height" value="px"/>
                </reportElement>
                <box>
                    <topPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                    <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                    <bottomPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                    <rightPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                </box>
                <textElement verticalAlignment="Middle">
                    <font fontName="华文宋体" size="16"/>
                </textElement>
                <textFieldExpression><![CDATA[$P{contractName}]]></textFieldExpression>
            </textField>
            <staticText>
                <reportElement x="0" y="0" width="150" height="100" uuid="8473a83f-ab29-487b-970c-934e474335ef">
                    <property name="com.jaspersoft.studio.unit.x" value="px"/>
                    <property name="com.jaspersoft.studio.unit.y" value="px"/>
                    <property name="com.jaspersoft.studio.unit.width" value="px"/>
                    <property name="com.jaspersoft.studio.unit.height" value="px"/>
                </reportElement>
                <box>
                    <topPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                    <leftPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                    <bottomPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                    <rightPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                </box>
                <text><![CDATA[]]></text>
            </staticText>
            <image>
                <reportElement x="5" y="5" width="145" height="95" uuid="f46728b5-d7ab-42a4-acf9-27918b0cdfcf">
                    <property name="com.jaspersoft.studio.unit.x" value="px"/>
                    <property name="com.jaspersoft.studio.unit.y" value="px"/>
                    <property name="com.jaspersoft.studio.unit.width" value="px"/>
                    <property name="com.jaspersoft.studio.unit.height" value="px"/>
                </reportElement>
                <imageExpression><![CDATA[com.google.zxing.client.j2se.MatrixToImageWriter.toBufferedImage(
 new com.google.zxing.qrcode.QRCodeWriter().encode(
   $P{contractCode},
 com.google.zxing.BarcodeFormat.QR_CODE, 300, 300))]]></imageExpression>
            </image>
        </band>
    </title>
    <detail>
        <band height="464" splitType="Stretch">
            <textField>
                <reportElement x="80" y="0" width="195" height="50" uuid="105c1af1-a467-476b-bb55-d922f5430cf1">
                    <property name="com.jaspersoft.studio.unit.x" value="px"/>
                    <property name="com.jaspersoft.studio.unit.y" value="px"/>
                    <property name="com.jaspersoft.studio.unit.width" value="px"/>
                    <property name="com.jaspersoft.studio.unit.height" value="px"/>
                </reportElement>
                <textElement textAlignment="Left" verticalAlignment="Middle">
                    <font size="12"/>
                </textElement>
                <textFieldExpression><![CDATA[$P{contractCode}]]></textFieldExpression>
            </textField>
            <staticText>
                <reportElement x="0" y="0" width="275" height="50" uuid="2d6d679e-0c9f-4441-89b1-7967ab7921a1">
                    <property name="com.jaspersoft.studio.unit.x" value="px"/>
                    <property name="com.jaspersoft.studio.unit.y" value="px"/>
                    <property name="com.jaspersoft.studio.unit.width" value="px"/>
                    <property name="com.jaspersoft.studio.unit.height" value="px"/>
                    <property name="com.jaspersoft.studio.unit.rightIndent" value="pixel"/>
                    <property name="com.jaspersoft.studio.unit.leftIndent" value="px"/>
                </reportElement>
                <box>
                    <topPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                    <leftPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                    <bottomPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                    <rightPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                </box>
                <textElement verticalAlignment="Middle">
                    <font fontName="华文宋体" size="12"/>
                    <paragraph leftIndent="10"/>
                </textElement>
                <text><![CDATA[合同编号:]]></text>
            </staticText>
            <staticText>
                <reportElement x="275" y="0" width="275" height="50" uuid="d0d70e61-450b-4f07-b4ec-6fa32e324c5f">
                    <property name="com.jaspersoft.studio.unit.x" value="px"/>
                    <property name="com.jaspersoft.studio.unit.y" value="px"/>
                    <property name="com.jaspersoft.studio.unit.width" value="px"/>
                    <property name="com.jaspersoft.studio.unit.height" value="px"/>
                    <property name="com.jaspersoft.studio.unit.rightIndent" value="pixel"/>
                    <property name="com.jaspersoft.studio.unit.leftIndent" value="px"/>
                </reportElement>
                <box>
                    <topPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                    <leftPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                    <bottomPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                    <rightPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                </box>
                <textElement verticalAlignment="Middle">
                    <font fontName="华文宋体" size="12"/>
                    <paragraph leftIndent="10"/>
                </textElement>
                <text><![CDATA[原始合同编号:]]></text>
            </staticText>
            <textField>
                <reportElement x="375" y="0" width="175" height="50" uuid="6237f581-8f82-4a96-a8d8-e6bde73365ed">
                    <property name="com.jaspersoft.studio.unit.x" value="px"/>
                    <property name="com.jaspersoft.studio.unit.y" value="px"/>
                    <property name="com.jaspersoft.studio.unit.width" value="px"/>
                    <property name="com.jaspersoft.studio.unit.height" value="px"/>
                </reportElement>
                <textElement textAlignment="Left" verticalAlignment="Middle">
                    <font fontName="华文宋体" size="12"/>
                </textElement>
                <textFieldExpression><![CDATA[$P{contractOriginalCode}]]></textFieldExpression>
            </textField>
            <staticText>
                <reportElement x="0" y="50" width="275" height="50" uuid="c0dde391-626a-4a4d-a30e-9c6a96471094">
                    <property name="com.jaspersoft.studio.unit.x" value="px"/>
                    <property name="com.jaspersoft.studio.unit.y" value="px"/>
                    <property name="com.jaspersoft.studio.unit.width" value="px"/>
                    <property name="com.jaspersoft.studio.unit.height" value="px"/>
                    <property name="com.jaspersoft.studio.unit.rightIndent" value="pixel"/>
                    <property name="com.jaspersoft.studio.unit.leftIndent" value="px"/>
                </reportElement>
                <box>
                    <topPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                    <leftPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                    <bottomPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                    <rightPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                </box>
                <textElement verticalAlignment="Middle">
                    <font fontName="华文宋体" size="12"/>
                    <paragraph leftIndent="10"/>
                </textElement>
                <text><![CDATA[合同原币金额: ]]></text>
            </staticText>
            <textField pattern="#,###.000000">
                <reportElement x="100" y="50" width="175" height="50" uuid="31dffff6-2b8c-495d-a4ba-4f0dedcb5a2e">
                    <property name="com.jaspersoft.studio.unit.x" value="px"/>
                    <property name="com.jaspersoft.studio.unit.y" value="px"/>
                    <property name="com.jaspersoft.studio.unit.width" value="px"/>
                    <property name="com.jaspersoft.studio.unit.height" value="px"/>
                </reportElement>
                <textElement textAlignment="Left" verticalAlignment="Middle">
                    <font fontName="华文宋体" size="12"/>
                </textElement>
                <textFieldExpression><![CDATA[$P{originalCcyTaxIncludedAmt}]]></textFieldExpression>
            </textField>
            <staticText>
                <reportElement x="275" y="50" width="275" height="50" uuid="e58f269c-3bf0-4909-bf43-10c416490ef4">
                    <property name="com.jaspersoft.studio.unit.x" value="px"/>
                    <property name="com.jaspersoft.studio.unit.y" value="px"/>
                    <property name="com.jaspersoft.studio.unit.width" value="px"/>
                    <property name="com.jaspersoft.studio.unit.height" value="px"/>
                    <property name="com.jaspersoft.studio.unit.rightIndent" value="pixel"/>
                    <property name="com.jaspersoft.studio.unit.leftIndent" value="px"/>
                </reportElement>
                <box>
                    <topPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                    <leftPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                    <bottomPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                    <rightPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                </box>
                <textElement verticalAlignment="Middle">
                    <font fontName="华文宋体" size="12"/>
                    <paragraph leftIndent="10"/>
                </textElement>
                <text><![CDATA[合同本币金额: ]]></text>
            </staticText>
            <textField pattern="#,###.000000">
                <reportElement x="375" y="50" width="175" height="50" uuid="75671f56-f645-4d3b-9c23-a22aa9db24ac">
                    <property name="com.jaspersoft.studio.unit.x" value="px"/>
                    <property name="com.jaspersoft.studio.unit.y" value="px"/>
                    <property name="com.jaspersoft.studio.unit.width" value="px"/>
                    <property name="com.jaspersoft.studio.unit.height" value="px"/>
                </reportElement>
                <textElement textAlignment="Left" verticalAlignment="Middle">
                    <font fontName="华文宋体" size="12"/>
                </textElement>
                <textFieldExpression><![CDATA[$P{localCcyTaxIncludedAmt}]]></textFieldExpression>
            </textField>
            <staticText>
                <reportElement x="0" y="100" width="275" height="50" uuid="78effebc-f57c-4f42-8d9e-7e135bff5823">
                    <property name="com.jaspersoft.studio.unit.x" value="px"/>
                    <property name="com.jaspersoft.studio.unit.y" value="px"/>
                    <property name="com.jaspersoft.studio.unit.width" value="px"/>
                    <property name="com.jaspersoft.studio.unit.height" value="px"/>
                    <property name="com.jaspersoft.studio.unit.rightIndent" value="pixel"/>
                    <property name="com.jaspersoft.studio.unit.leftIndent" value="px"/>
                </reportElement>
                <box>
                    <topPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                    <leftPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                    <bottomPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                    <rightPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                </box>
                <textElement verticalAlignment="Middle">
                    <font fontName="华文宋体" size="12"/>
                    <paragraph leftIndent="10"/>
                </textElement>
                <text><![CDATA[合同类型: ]]></text>
            </staticText>
            <textField>
                <reportElement x="80" y="100" width="195" height="50" uuid="53bc851c-2240-4725-9f59-9b338b3ad673">
                    <property name="com.jaspersoft.studio.unit.x" value="px"/>
                    <property name="com.jaspersoft.studio.unit.y" value="px"/>
                    <property name="com.jaspersoft.studio.unit.width" value="px"/>
                    <property name="com.jaspersoft.studio.unit.height" value="px"/>
                </reportElement>
                <textElement textAlignment="Left" verticalAlignment="Middle">
                    <font fontName="华文宋体" size="12"/>
                </textElement>
                <textFieldExpression><![CDATA[$P{contractType}]]></textFieldExpression>
            </textField>
            <staticText>
                <reportElement x="275" y="100" width="275" height="50" uuid="b39bc59f-95ad-4710-a489-ee733633821a">
                    <property name="com.jaspersoft.studio.unit.x" value="px"/>
                    <property name="com.jaspersoft.studio.unit.y" value="px"/>
                    <property name="com.jaspersoft.studio.unit.width" value="px"/>
                    <property name="com.jaspersoft.studio.unit.height" value="px"/>
                    <property name="com.jaspersoft.studio.unit.rightIndent" value="pixel"/>
                    <property name="com.jaspersoft.studio.unit.leftIndent" value="px"/>
                </reportElement>
                <box>
                    <topPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                    <leftPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                    <bottomPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                    <rightPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                </box>
                <textElement verticalAlignment="Middle">
                    <font fontName="华文宋体" size="12"/>
                    <paragraph leftIndent="10"/>
                </textElement>
                <text><![CDATA[合同明细类型: ]]></text>
            </staticText>
            <textField>
                <reportElement x="380" y="100" width="175" height="50" uuid="c2934c57-e873-45b9-826e-4cb710371329">
                    <property name="com.jaspersoft.studio.unit.x" value="px"/>
                    <property name="com.jaspersoft.studio.unit.y" value="px"/>
                    <property name="com.jaspersoft.studio.unit.width" value="px"/>
                    <property name="com.jaspersoft.studio.unit.height" value="px"/>
                </reportElement>
                <textElement textAlignment="Left" verticalAlignment="Middle">
                    <font fontName="华文宋体" size="12"/>
                </textElement>
                <textFieldExpression><![CDATA[$P{contractDetailType}]]></textFieldExpression>
            </textField>
            <staticText>
                <reportElement x="0" y="150" width="275" height="50" uuid="9819c616-bdaa-4a3e-a6ba-9a4b32d83504">
                    <property name="com.jaspersoft.studio.unit.x" value="px"/>
                    <property name="com.jaspersoft.studio.unit.y" value="px"/>
                    <property name="com.jaspersoft.studio.unit.width" value="px"/>
                    <property name="com.jaspersoft.studio.unit.height" value="px"/>
                    <property name="com.jaspersoft.studio.unit.rightIndent" value="pixel"/>
                    <property name="com.jaspersoft.studio.unit.leftIndent" value="px"/>
                </reportElement>
                <box>
                    <topPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                    <leftPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                    <bottomPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                    <rightPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                </box>
                <textElement verticalAlignment="Middle">
                    <font fontName="华文宋体" size="12"/>
                    <paragraph leftIndent="10"/>
                </textElement>
                <text><![CDATA[供应商: ]]></text>
            </staticText>
            <textField>
                <reportElement x="75" y="150" width="200" height="50" uuid="a19b1811-472a-4a13-88c4-0a1de911be63">
                    <property name="com.jaspersoft.studio.unit.x" value="px"/>
                    <property name="com.jaspersoft.studio.unit.y" value="px"/>
                    <property name="com.jaspersoft.studio.unit.width" value="px"/>
                    <property name="com.jaspersoft.studio.unit.height" value="px"/>
                </reportElement>
                <textElement textAlignment="Left" verticalAlignment="Middle">
                    <font fontName="华文宋体" size="12"/>
                </textElement>
                <textFieldExpression><![CDATA[$P{supplierName}]]></textFieldExpression>
            </textField>
            <staticText>
                <reportElement x="275" y="150" width="275" height="50" uuid="ec87b19f-5c46-4cc0-a905-db71866a8bcb">
                    <property name="com.jaspersoft.studio.unit.x" value="px"/>
                    <property name="com.jaspersoft.studio.unit.y" value="px"/>
                    <property name="com.jaspersoft.studio.unit.width" value="px"/>
                    <property name="com.jaspersoft.studio.unit.height" value="px"/>
                    <property name="com.jaspersoft.studio.unit.rightIndent" value="pixel"/>
                    <property name="com.jaspersoft.studio.unit.leftIndent" value="px"/>
                </reportElement>
                <box>
                    <topPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                    <leftPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                    <bottomPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                    <rightPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                </box>
                <textElement verticalAlignment="Middle">
                    <font fontName="华文宋体" size="12"/>
                    <paragraph leftIndent="10"/>
                </textElement>
                <text><![CDATA[经办人: ]]></text>
            </staticText>
            <textField>
                <reportElement x="360" y="150" width="190" height="50" uuid="51924948-0620-4640-83f1-2dccde027ce7">
                    <property name="com.jaspersoft.studio.unit.x" value="px"/>
                    <property name="com.jaspersoft.studio.unit.y" value="px"/>
                    <property name="com.jaspersoft.studio.unit.width" value="px"/>
                    <property name="com.jaspersoft.studio.unit.height" value="px"/>
                </reportElement>
                <textElement textAlignment="Left" verticalAlignment="Middle">
                    <font fontName="华文宋体" size="12"/>
                </textElement>
                <textFieldExpression><![CDATA[$P{operatorName}]]></textFieldExpression>
            </textField>
            <staticText>
                <reportElement x="0" y="200" width="275" height="50" uuid="be7ce37b-e71c-4672-81ca-1107c7c63aa3">
                    <property name="com.jaspersoft.studio.unit.x" value="px"/>
                    <property name="com.jaspersoft.studio.unit.y" value="px"/>
                    <property name="com.jaspersoft.studio.unit.width" value="px"/>
                    <property name="com.jaspersoft.studio.unit.height" value="px"/>
                    <property name="com.jaspersoft.studio.unit.rightIndent" value="pixel"/>
                    <property name="com.jaspersoft.studio.unit.leftIndent" value="px"/>
                </reportElement>
                <box>
                    <topPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                    <leftPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                    <bottomPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                    <rightPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                </box>
                <textElement verticalAlignment="Middle">
                    <font fontName="华文宋体" size="12"/>
                    <paragraph leftIndent="10"/>
                </textElement>
                <text><![CDATA[经办机构: ]]></text>
            </staticText>
            <textField>
                <reportElement x="80" y="200" width="195" height="50" uuid="0ec536ab-e009-4f1b-a53d-b5e6cf4a7517">
                    <property name="com.jaspersoft.studio.unit.x" value="px"/>
                    <property name="com.jaspersoft.studio.unit.y" value="px"/>
                    <property name="com.jaspersoft.studio.unit.width" value="px"/>
                    <property name="com.jaspersoft.studio.unit.height" value="px"/>
                </reportElement>
                <textElement textAlignment="Left" verticalAlignment="Middle">
                    <font fontName="华文宋体" size="12"/>
                </textElement>
                <textFieldExpression><![CDATA[$P{operatorOrgName}]]></textFieldExpression>
            </textField>
            <staticText>
                <reportElement x="275" y="200" width="275" height="50" uuid="ddfd21bf-8765-47ac-9b9f-1df0723d4a6e">
                    <property name="com.jaspersoft.studio.unit.x" value="px"/>
                    <property name="com.jaspersoft.studio.unit.y" value="px"/>
                    <property name="com.jaspersoft.studio.unit.width" value="px"/>
                    <property name="com.jaspersoft.studio.unit.height" value="px"/>
                    <property name="com.jaspersoft.studio.unit.rightIndent" value="pixel"/>
                    <property name="com.jaspersoft.studio.unit.leftIndent" value="px"/>
                </reportElement>
                <box>
                    <topPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                    <leftPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                    <bottomPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                    <rightPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                </box>
                <textElement verticalAlignment="Middle">
                    <font fontName="华文宋体" size="12"/>
                    <paragraph leftIndent="10"/>
                </textElement>
                <text><![CDATA[经办部门: ]]></text>
            </staticText>
            <textField>
                <reportElement x="380" y="200" width="170" height="50" uuid="c9fd0aeb-4107-4e50-98b6-ceeb92dd1f9e">
                    <property name="com.jaspersoft.studio.unit.x" value="px"/>
                    <property name="com.jaspersoft.studio.unit.y" value="px"/>
                    <property name="com.jaspersoft.studio.unit.width" value="px"/>
                    <property name="com.jaspersoft.studio.unit.height" value="px"/>
                </reportElement>
                <textElement textAlignment="Left" verticalAlignment="Middle">
                    <font fontName="华文宋体" size="12"/>
                </textElement>
                <textFieldExpression><![CDATA[$P{operatorDeptName}]]></textFieldExpression>
            </textField>
            <staticText>
                <reportElement x="0" y="250" width="275" height="50" uuid="7a44b93c-dbf8-4b89-84b1-17526e7a42fd">
                    <property name="com.jaspersoft.studio.unit.x" value="px"/>
                    <property name="com.jaspersoft.studio.unit.y" value="px"/>
                    <property name="com.jaspersoft.studio.unit.width" value="px"/>
                    <property name="com.jaspersoft.studio.unit.height" value="px"/>
                    <property name="com.jaspersoft.studio.unit.rightIndent" value="pixel"/>
                    <property name="com.jaspersoft.studio.unit.leftIndent" value="px"/>
                </reportElement>
                <box>
                    <topPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                    <leftPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                    <bottomPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                    <rightPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                </box>
                <textElement verticalAlignment="Middle">
                    <font fontName="华文宋体" size="12"/>
                    <paragraph leftIndent="10"/>
                </textElement>
                <text><![CDATA[合同生效日: ]]></text>
            </staticText>
            <textField pattern="yyyy-MM-dd">
                <reportElement x="100" y="250" width="175" height="50" uuid="6e66816d-8d93-4384-8e67-b4e706cd32af">
                    <property name="com.jaspersoft.studio.unit.x" value="px"/>
                    <property name="com.jaspersoft.studio.unit.y" value="px"/>
                    <property name="com.jaspersoft.studio.unit.width" value="px"/>
                    <property name="com.jaspersoft.studio.unit.height" value="px"/>
                </reportElement>
                <textElement textAlignment="Left" verticalAlignment="Middle">
                    <font fontName="华文宋体" size="12"/>
                </textElement>
                <textFieldExpression><![CDATA[$P{effectiveDate}]]></textFieldExpression>
            </textField>
            <staticText>
                <reportElement x="275" y="250" width="275" height="50" uuid="bbeb9256-f69e-4e23-9ea2-7e50336f3953">
                    <property name="com.jaspersoft.studio.unit.x" value="px"/>
                    <property name="com.jaspersoft.studio.unit.y" value="px"/>
                    <property name="com.jaspersoft.studio.unit.width" value="px"/>
                    <property name="com.jaspersoft.studio.unit.height" value="px"/>
                    <property name="com.jaspersoft.studio.unit.rightIndent" value="pixel"/>
                    <property name="com.jaspersoft.studio.unit.leftIndent" value="px"/>
                </reportElement>
                <box>
                    <topPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                    <leftPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                    <bottomPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                    <rightPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                </box>
                <textElement verticalAlignment="Middle">
                    <font fontName="华文宋体" size="12"/>
                    <paragraph leftIndent="10"/>
                </textElement>
                <text><![CDATA[合同到期日: ]]></text>
            </staticText>
            <textField pattern="yyyy-MM-dd">
                <reportElement x="380" y="250" width="170" height="50" uuid="b7733675-2d10-4bfb-ac51-7b4674b7bde0">
                    <property name="com.jaspersoft.studio.unit.x" value="px"/>
                    <property name="com.jaspersoft.studio.unit.y" value="px"/>
                    <property name="com.jaspersoft.studio.unit.width" value="px"/>
                    <property name="com.jaspersoft.studio.unit.height" value="px"/>
                </reportElement>
                <textElement textAlignment="Left" verticalAlignment="Middle">
                    <font fontName="华文宋体" size="12"/>
                </textElement>
                <textFieldExpression><![CDATA[$P{expiredDate}]]></textFieldExpression>
            </textField>
        </band>
    </detail>
    <pageFooter>
        <band height="54" splitType="Stretch"/>
    </pageFooter>
    <summary>
        <band height="42" splitType="Stretch"/>
    </summary>
</jasperReport>

  1. jar包上传到本地maven库或者公司的私服
mvn install:install-file -Dfile=iTextAsian.jar -DgroupId=io.github.meta-ease -DartifactId=iTextAsian -Dversion=1.0.0 -Dpackaging=jar
  1. 应用依赖jar包正常导出含有中文的PDF
      <dependency>
            <groupId>io.github.meta-ease</groupId>
            <artifactId>iTextAsian</artifactId>
            <version>1.0.0</version>
        </dependency>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

DevBug

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值