Я использовал IReport 5.6.0, и я использовал jhipster, я работаю под сервером Windows.
У меня есть папка с именем report под ресурсами src -> main ->, и я поместил в нее myReport.jasper. папка
У меня есть эта конфигурация для использования jasperreports в моем проекте:
<dependency>
<groupId>net.sf.jasperreports</groupId>
<artifactId>jasperreports</artifactId>
<version>5.6.0</version>
</dependency>
<dependency>
<groupId>net.sf.jasperreports</groupId>
<artifactId>jasperreports-fonts</artifactId>
<version>6.10</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/jasperreports-fonts-6.10.0.jar</systemPath>
</dependency>
У меня есть изменение font.xmlв jasperreports-fonts-6.10.0.jar
fontFamily name="Arial">
<normal>net/sf/jasperreports/fonts/dejavu/arial.ttf</normal>
<bold>net/sf/jasperreports/fonts/dejavu/arialbd.ttf</bold>
<italic>net/sf/jasperreports/fonts/dejavu/ariali.ttf</italic>
<boldItalic>net/sf/jasperreports/fonts/dejavu/arialbi.ttf</boldItalic>
<pdfEncoding>Cp1256</pdfEncoding>
<pdfEmbedded>true</pdfEmbedded>
<locales>
<locale>en_US</locale>
<locale>ar_SA</locale>
</locales>
</fontFamily>
<fontFamily name="FS_Diwany">
<normal>net/sf/jasperreports/fonts/dejavu/fsdiwany.ttf</normal>
<pdfEncoding>Cp1256</pdfEncoding>
<pdfEmbedded>false</pdfEmbedded>
</fontFamily>
и я добавил файлы ttf в этот jar (по этому пути net / sf / jasperreports / fonts / dejavu)
, но когдаЯ проверяю, у меня есть эта ошибка:
net.sf.jasperreports.engine.JRRuntimeException: Could not load the following font :
pdfFontName : arial.ttf
pdfEncoding : Identity-H
isPdfEmbedded : false
at net.sf.jasperreports.engine.export.JRPdfExporter.getFont(JRPdfExporter.java:2116)
at net.sf.jasperreports.engine.export.JRPdfExporter.getChunk(JRPdfExporter.java:1906)
at net.sf.jasperreports.engine.export.JRPdfExporter.getPhrase(JRPdfExporter.java:1875)
at net.sf.jasperreports.engine.export.SimplePdfTextRenderer.getPhrase(SimplePdfTextRenderer.java:89)
это jasperReport.xml
<?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="CorrespondenceReport_ar" columnDirection="RTL" pageWidth="595" pageHeight="842" whenNoDataType="NoDataSection" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" isFloatColumnFooter="true" uuid="1a092fe1-2262-42d1-942c-731b3242aab2">
<property name="ireport.zoom" value="1.0"/>
<property name="ireport.x" value="0"/>
<property name="ireport.y" value="0"/>
<style name="table">
<box>
<pen lineWidth="1.0" lineColor="#000000"/>
</box>
</style>
<style name="table_TH" mode="Opaque" backcolor="#8FAFCC">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="table_CH" mode="Opaque" backcolor="#CFDBE6">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="table_TD" mode="Opaque" backcolor="#FFFFFF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
</box>
<conditionalStyle>
<conditionExpression><![CDATA[new Boolean($V{REPORT_COUNT}.intValue()%2==0)]]></conditionExpression>
<style backcolor="#F3F6F8"/>
</conditionalStyle>
</style>
<style name="table 1">
<box>
<pen lineWidth="1.0" lineColor="#000000"/>
</box>
</style>
<style name="table 1_TH" mode="Opaque" backcolor="#8FAFCC">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="table 1_CH" mode="Opaque" backcolor="#CFDBE6">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="table 1_TD" mode="Opaque" backcolor="#FFFFFF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
</box>
<conditionalStyle>
<conditionExpression><![CDATA[new Boolean($V{REPORT_COUNT}.intValue()%2==0)]]></conditionExpression>
<style backcolor="#F3F6F8"/>
</conditionalStyle>
</style>
<style name="table 2">
<box>
<pen lineWidth="1.0" lineColor="#000000"/>
</box>
</style>
<style name="table 2_TH" mode="Opaque" backcolor="#F0F8FF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="table 2_CH" mode="Opaque" backcolor="#BFE1FF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="table 2_TD" mode="Opaque" backcolor="#FFFFFF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<parameter name="id_leave" class="java.lang.String">
<defaultValueExpression><![CDATA[]]></defaultValueExpression>
</parameter>
<queryString>
<![CDATA[]]>
</queryString>
<field name="owner_empLeave" class="java.lang.String"/>
<field name="nationality" class="java.lang.String"/>
<title>
<band height="365">
<staticText>
<reportElement mode="Transparent" x="182" y="42" width="152" height="17" forecolor="#000066" uuid="ab2b98ba-82f0-4cec-91cc-0d22bcf5e18d"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="Arial" size="14" isBold="true" pdfFontName="arial.ttf" pdfEncoding="Identity-H" isPdfEmbedded="true"/>
</textElement>
<text><![CDATA[Unversity]]></text>
</staticText>
<staticText>
<reportElement mode="Transparent" x="143" y="128" width="305" height="27" forecolor="#000066" uuid="9d2d8bda-af45-4d05-bef5-5eeb485b5d42"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="Arial" size="18" isBold="true" isItalic="false" isUnderline="false" pdfFontName="arial.ttf" pdfEncoding="Identity-H" isPdfEmbedded="true"/>
</textElement>
<text><![CDATA[TO WHOM IT MAY CONCERN]]></text>
</staticText>
<textField isBlankWhenNull="true">
<reportElement positionType="Float" stretchType="RelativeToBandHeight" x="132" y="175" width="337" height="23" forecolor="#003399" uuid="1fc628cc-c54a-4d4d-9599-0f08def4c887"/>
<textElement textAlignment="Left" verticalAlignment="Middle">
<font fontName="Arial" size="11" isBold="true" pdfFontName="arial.ttf" pdfEncoding="Identity-H" isPdfEmbedded="true"/>
<paragraph rightIndent="10"/>
</textElement>
<textFieldExpression><![CDATA[$F{owner_empLeave}]]></textFieldExpression>
</textField>
<staticText>
<reportElement positionType="Float" stretchType="RelativeToBandHeight" mode="Opaque" x="12" y="175" width="120" height="23" uuid="fc6bac67-d97e-4a94-8155-a5d29ce44173"/>
<textElement textAlignment="Left" verticalAlignment="Middle">
<font fontName="Arial" size="11" isBold="true" pdfFontName="arial.ttf" pdfEncoding="Identity-H" isPdfEmbedded="true"/>
</textElement>
<text><![CDATA[This is to certify that]]></text>
</staticText>
<staticText>
<reportElement positionType="Float" stretchType="RelativeToBandHeight" mode="Opaque" x="89" y="204" width="331" height="23" uuid="eaea0874-6ef5-4ebb-bf0f-e38fc0007208"/>
<textElement textAlignment="Left" verticalAlignment="Middle">
<font fontName="Arial" size="11" isBold="true" pdfFontName="arial.ttf" pdfEncoding="Identity-H" isPdfEmbedded="true"/>
</textElement>
<text><![CDATA[National ) is employed at this University ]]></text>
</staticText>
<textField isBlankWhenNull="true">
<reportElement positionType="Float" stretchType="RelativeToBandHeight" x="12" y="206" width="85" height="19" forecolor="#003399" uuid="d87bc24a-dba8-4e94-b48a-390475e3d035"/>
<textElement textAlignment="Left" verticalAlignment="Middle">
<font fontName="Arial" size="11" isBold="true" pdfFontName="arial.ttf" pdfEncoding="Identity-H" isPdfEmbedded="true"/>
<paragraph rightIndent="10"/>
</textElement>
<textFieldExpression><![CDATA["( "+$F{nationality}]]></textFieldExpression>
</textField>
</band>
</title>
<columnFooter>
<band height="210" splitType="Immediate"/>
</columnFooter>
<noData>
<band height="35"/>
</noData>
</jasperReport>
обновлено:
также я пытаюсь с другимиконфигурация:
добавление jasper-extensions.properties к ресурсам:
net.sf.jasperreports.extension.registry.factory.fonts=net.sf.jasperreports.engine.fonts.SimpleFontExtensionsRegistryFactory
net.sf.jasperreports.extension.simple.font.families.ireportfamily1346674315158=fonts/fonts.xml
создание папки шрифтов, содержащей файлы arial.ttf и font.xml
<?xml version="1.0" encoding="UTF-8"?>
<fontFamilies>
<fontFamily name="Arial">
<normal><![CDATA[fonts/arial.ttf]]></normal>
<bold><![CDATA[fonts/arialbd.ttf]]></bold>
<italic><![CDATA[fonts/ariali.ttf]]></italic>
<boldItalic><![CDATA[fonts/arialbi.ttf]]></boldItalic>
<pdfEncoding><![CDATA[Cp1256]]></pdfEncoding>
<pdfEmbedded><![CDATA[true]]></pdfEmbedded>
<locales>
<locale><![CDATA[en_US]]></locale>
<locale><![CDATA[ar_SA]]></locale>
</locales>
</fontFamily>
<fontFamily name="FS_Diwany">
<normal><![CDATA[fonts/fsdiwany.ttf]]></normal>
<pdfEncoding><![CDATA[Cp1256]]></pdfEncoding>
<pdfEmbedded><![CDATA[false]]></pdfEmbedded>
</fontFamily>
</fontFamilies>
, но когда ятест У меня такая же ошибка.
Я думаю, что проблема связана с ошибкой расположения файлов jasper-extensions.properties иfont.xml