2015-11-05 79 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上找到它,搜索互聯網或切換字體。 –

相關問題