I am facing the problem, that JasperReports still cannot find the Arial font.
I created a simple Maven Project with following structure and included it to my main application. So the main application contains the installed JAR in classpath:
- jasperreports_extension.properties
- fonts
|-> arial
|-> ariali.ttf
|-> arialbi.ttf
|-> arialbd.ttf
|-> arial.ttf
|-> fonts.xml
But I still see following Exception while exporting report to PDF.
net.sf.jasperreports.engine.JRRuntimeException: Could not load the following font :
pdfFontName : Arial
pdfEncoding : Identity-H
isPdfEmbedded : true
jasperreports_extension.properties
net.sf.jasperreports.extension.registry.factory.simple.font.families=net.sf.jasperreports.engine.fonts.SimpleFontExtensionsRegistryFactory
net.sf.jasperreports.extension.simple.font.families.arial=fonts/fonts.xml
fonts.xml:
<?xml version="1.0" encoding="UTF-8"?>
<fontFamilies>
<fontFamily name="Arial">
<normal>fonts/arial/arial.ttf</normal>
<bold>fonts/arial/arialbd.ttf</bold>
<italic>fonts/arial/ariali.ttf</italic>
<boldItalic>fonts/arial/arialbi.ttf</boldItalic>
<pdfEncoding>Identity-H</pdfEncoding>
<pdfEmbedded>true</pdfEmbedded>
</fontFamily>
</fontFamilies>
Template
<font fontName="Arial" size="8" pdfFontName="Arial" pdfEncoding="Identity-H" isPdfEmbedded="true"/>
The problem was the template itself: At one font-tag the <fontName>
property was missing:
Does not work:
<font size="12" isBold="true" pdfFontName="Arial"/>
Does work:
<font fontName="Arial" size="12" isBold="true" pdfFontName="Arial" pdfEncoding="Identity-H" isPdfEmbedded="true"/>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With