【问题标题】:iReport and Jasperreport fonts for a PDF report用于 PDF 报告的 iReport 和 Jasperreport 字体
【发布时间】:2015-11-05 17:12:46
【问题描述】:

我使用 iReport 使用一些默认字体(等宽字体、无衬线字体)制作了一份报告。 该报告有点复杂,许多静态元素的位置都经过计算以适合标签的宽度。 举个例子: 其中“test of a long string...”是字段内容,框是静态元素。 如您所见,我需要一个精确的字符大小。

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>

【问题讨论】:

  • 您是否尝试在pdf中包含字体?,传递相关的jrxml代码
  • community.jaspersoft.com/wiki/…,至少你会使用相同的字体...
  • 我使用默认 ireport 字体:等宽字体和无衬线字体。它们存储在哪里,如何复制 ireport 流程?字体是否存储在 .jasper 编译文件中?

标签: fonts jasper-reports ireport


【解决方案1】:

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

这样的代码

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

因为 Jasper 6.0 这是deprecated,你应该使用字体扩展

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

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

【讨论】:

  • 我没有使用 Windows 的字体,而是 JVM(或 ireport?)字体:Monospace 和 SansSerif。我只想在我的 java 应用中复制相同的 ireport 预览过程。
  • 而且 pdf 没有使用 JVM 字体......你需要一个 TrueType 字体,这样你就可以将它添加为字体扩展......如果你在电脑上找不到它,搜索互联网或切换字体。
猜你喜欢
  • 2023-03-28
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多