Exporting to PDF results net.sf.jasperreports.engine.JRRuntimeException: Could not load the following font

2

Hi,

I am using Jasper reports library version 5.0.1, and I am trying to export report to PDF. I've configuration to use 'Noto Sans' as default font and 'net.sf.jasperreports.default.pdf.embedded' set to true. 'Noto Sans' font files are added to classpath as part of Font extension.

But when I try to export my report to PDF, I get the below given exception

net.sf.jasperreports.engine.JRRuntimeException: Could not load the following font :
pdfFontName   : Noto Sans
pdfEncoding   : Cp1252
isPdfEmbedded : true
    at net.sf.jasperreports.engine.export.JRPdfExporter.getFont(JRPdfExporter.java:2042)
    at net.sf.jasperreports.engine.export.JRPdfExporter.getChunk(JRPdfExporter.java:1805)
    at net.sf.jasperreports.engine.export.JRPdfExporter.getPhrase(JRPdfExporter.java:1774)
    at net.sf.jasperreports.engine.export.SimplePdfTextRenderer.getPhrase(SimplePdfTextRenderer.java:89)
    at net.sf.jasperreports.engine.export.SimplePdfTextRenderer.render(SimplePdfTextRenderer.java:99)
    at net.sf.jasperreports.engine.export.JRPdfExporter.exportText(JRPdfExporter.java:2164)
    at net.sf.jasperreports.engine.export.JRPdfExporter.exportElements(JRPdfExporter.java:858)
    at net.sf.jasperreports.engine.export.JRPdfExporter.exportPage(JRPdfExporter.java:818)
    at net.sf.jasperreports.engine.export.JRPdfExporter.exportReportToStream(JRPdfExporter.java:695)
    at net.sf.jasperreports.engine.export.JRPdfExporter.exportReport(JRPdfExporter.java:396)

my font extension configuration is as follows

net.sf.jasperreports.extension.registry.factory.fonts=net.sf.jasperreports.engine.fonts.SimpleFontExtensionsRegistryFactory
net.sf.jasperreports.extension.simple.font.families.ireportfamily=font-families.xml
<?xml version="1.0" encoding="UTF-8"?>
<fontFamilies>
 
   <fontFamily name="Noto Sans">
       <normal><![CDATA[fonts/noto/NotoSans-Regular.ttf]]></normal>
       <bold><![CDATA[fonts/noto/NotoSans-Bold.ttf]]></bold>
       <italic><![CDATA[fonts/noto/NotoSans-Italic.ttf]]></italic>
       <boldItalic><![CDATA[fonts/noto/NotoSans-BoldItalic.ttf]]></boldItalic>
       <pdfEmbedded><![CDATA[true]]></pdfEmbedded>
       <exportFonts>
               <export key="net.sf.jasperreports.rtf"><![CDATA["Noto Sans", Arial, Helvetica, sans-serif]]></export>
               <export key="net.sf.jasperreports.xhtml"><![CDATA["Noto Sans", Arial, Helvetica, sans-serif]]></export>
               <export key="net.sf.jasperreports.html"><![CDATA["Noto Sans", Arial, Helvetica, sans-serif]]></export>
       </exportFonts>
   </fontFamily>
 
</fontFamilies>

can you please point out what could be the reason for the above exception?

Regards,

Rakesh.A

iamrakesh22's picture
Joined: Jan 10 2011 - 11:33pm
Last seen: 3 years 11 months ago

I am not able to reply to  the answer posted by Thomas below, hence this comment. 

@Thomas - Yes, if you see the fonts-families.xml, I posted above, all the .ttf files are in correct directories and the JAR is in classpath.

iamrakesh22 - 3 years 11 months ago

2 Answers:

0

Did you add the .ttf (font files) files to your application. Please check the below link

http://www.codesuggestions.com/java/jasper-reports/adding-custom-fonts-t...

AnnMary.Thomas's picture
Joined: Jun 18 2014 - 4:41am
Last seen: 2 years 5 months ago
0

Yes, if you see the fonts-families.xml, I posted above, all the .ttf files are in font extension JAR and it is in classpath.

iamrakesh22's picture
Joined: Jan 10 2011 - 11:33pm
Last seen: 3 years 11 months ago
Feedback
randomness