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
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"/>
In my case, I was using:
<font fontName="Arial" pdfEncoding="Identity-H" isPdfEmbedded="true"/>
I had to remove pdffontName
, the correct font tag is:
<font fontName="Arial" pdfEncoding="Cp1256"/>
Note I am using a font jar that contains the following .xml file:
<?xml version="1.0" encoding="UTF-8"?>
<fontFamilies>
<fontFamily name="Arial">
<normal><![CDATA[fonts/arial.ttf]]></normal>
<pdfEncoding><![CDATA[Identity-H]]></pdfEncoding>
<pdfEmbedded><![CDATA[true]]></pdfEmbedded>
</fontFamily>
</fontFamilies>
Another Solution Worked For Me is:
JRProperties.setProperty("net.sf.jasperreports.default.pdf.font.name", "Helvetica"); JRProperties.setProperty("net.sf.jasperreports.default.pdf.encoding", "UTF-8"); JRProperties.setProperty("net.sf.jasperreports.default.pdf.embedded", "true");
If you set parameters from java side, you have to specify font.name and Helvetica saves the day. I tried Arial here but threw the same error.
You must give the correct name of font for the PDF exporter. Your fonts are presents into the embedded fonts jar. You don't need to put them again into the classes directory ;-)
There is the correct fonts.xml content for pdf exporter (perhaps the names are case sensitive, be careful) :
<?xml version="1.0" encoding="UTF-8"?>
<fontFamilies>
<fontFamily name="Arial">
<normal>
<ttf>fonts/Arial/ARIAL.TTF</ttf>
<pdf>fonts/Arial/ARIAL.TTF</pdf>
</normal>
<bold>
<ttf>fonts/Arial/ARIALBD.TTF</ttf>
<pdf>fonts/Arial/ARIALBD.TTF</pdf>
</bold>
<italic>
<ttf>fonts/Arial/ARIALI.TTF</ttf>
<pdf>fonts/Arial/ARIALI.TTF</pdf>
</italic>
<boldItalic>
<ttf>fonts/Arial/ARIALBI.TTF</ttf>
<pdf>fonts/Arial/ARIALBI.TTF</pdf>
</boldItalic>
<pdfEncoding>Cp1252</pdfEncoding>
<pdfEmbedded>true</pdfEmbedded>
<exportFonts>
</exportFonts>
</fontFamily>
</fontFamilies>
I hope this help.
Regards, T.
Copy the fonts files (*.ttf) into the folder:
/path/to/app/WEB-INF/classes/***HERE***
You app will get the fonts from here :)