用于PDF报告的iReport和Jasperreport字体

时间:2015-11-05 17:12:46

标签: fonts jasper-reports ireport

我使用一些默认字体(monospace,sans-serif)使用iReport进行了报告。 此报告有点复杂,许多静态元素的位置计算得符合标签的宽度。 仅举例如: enter image description here 在哪里"测试长串......"是一个字段内容,框是静态元素。 如你所见,我需要一个精确的字符大小。

iReport预览很有效,但是当我使用JasperReport库进行报告时,字体大小与iReport预览完全不同,而且,等宽字体根本不存在。

如何准确创建像ireport预览一样的PDF报告?

这是JRXML头(完整文件是> 2000行):

<?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="107m" pageWidth="595" pageHeight="842" columnWidth="537" leftMargin="29" rightMargin="29" topMargin="20" bottomMargin="20" uuid="821aebb9-c4bd-4720-ae38-ae0f7e515398">
    <property name="ireport.zoom" value="1.4641000000000364"/>
    <property name="ireport.x" value="0"/>
    <property name="ireport.y" value="48"/>
    <property name="ireport.background.image" value="C:\v2(1).png"/>
    <property name="ireport.background.image.properties" value="true,true,0.25,1,-202,-7,184,612,865"/>
    <detail>
        <band height="801" splitType="Stretch">
            <staticText>
                <reportElement x="0" y="0" width="536" height="18" uuid="07f24965-4a55-49f1-bbaa-c7550bc6b37f"/>
                <textElement textAlignment="Center">
                    <font size="11"/>
                </textElement>
                <text><![CDATA[TITLE]]></text>
            </staticText>
            <staticText>
                <reportElement x="0" y="14" width="536" height="18" uuid="06b42267-0de9-4467-96cb-aa477c3f07c1"/>
                <textElement textAlignment="Center">
                    <font size="9" isBold="true"/>
                </textElement>
                <text><![CDATA[SUBTITLE]]></text>
            </staticText>

1 个答案:

答案 0 :(得分:0)

要在Jasper 6.0之前的pdf导出中使用相同的字体

像这样的代码

<font fontName="Times New Roman" pdfFontName="Times-Roman" isPdfEmbedded="true"/>

因为Jasper 6.0这是deprecated,你应该使用font-extension

对于如何在iReport中包含字体扩展名,这是一个很好的guide

编辑:我在哪里可以找到我的电脑上的字体?,在Windows上通常在C:\ Windows \ Fonts

相关问题