2015-11-05 157 views
0

我用iReport使用一些默认字体(等宽字体,无衬线字体)制作了报告。 这份报告有点复杂,许多静态元素的位置计算符合标签的宽度。 只是例如: enter image description here 其中“长字符串...的测试”是一个字段内容,并且这些框是静态元素。正如你所看到的,我需要一个精确的字符大小。PDF报告的iReport和Jasperreport字体

iReport预览效果很好,但是当我使用JasperReport库制作报告时,字体大小与iReport预览完全不同,此外,等宽字体完全不存在。

如何准确地创建一个PDF报告,如ireport预览?

这是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> 
+0

你试图在PDF的字体?通过相关JRXML代码问题 –

+0

HTTP ://community.jaspersoft.com/wiki/how-embed-fonts-jasperreport-ireport-generated-pdf-file,至少你会使用相同的字体... –

+0

我是默认的ireport字体:monospace和sansserif。他们在哪里存储,我如何复制ireport进程?字体是否存储在.jasper编译文件中? – Tobia

回答

0

要获得PDF导出相同的字体以前贾斯珀6.0您使用

这样的代码

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

自贾斯珀6.0这是deprecated,你应该使用字体扩展名

这是一个很好的guide如何在iReport中包含字体扩展。

编辑:我在哪里可以找到我的电脑字体?在Windows通常位于C:\ WINDOWS \字体

+0

我不使用Windows的字体,但使用JVM(或ireport?)字体:Monospace和SansSerif。我只想在我的java应用程序中复制ireport的相同预览过程。 – Tobia

+0

而pdf不使用JVM字体....你需要一个TrueType字体,所以你可以将它添加为字体扩展...如果你无法在PC上找到它,搜索互联网或切换字体。 –