No fonts on system

0

Hi,

I'm trying to generate a pdf on a system (container )where are no fonts.

I have a font jar with the font.xml with the font family description, the ttf fonts and the jasperreports_extension.properties file :

net.sf.jasperreports.extension.registry.factory.fonts=net.sf.jasperreports.engine.fonts.SimpleFontExtensionsRegistryFactory
net.sf.jasperreports.extension.simple.font.families.xxx=jasperreports/font/xxx.xml

Locally, everything works fine, but when I deploy on a different server I get this error:

net.sf.jasperreports.engine.JRRuntimeException: Error initializing graphic environment. at net.sf.jasperreports.engine.util.JRGraphEnvInitializer.initializeGraphEnv(JRGraphEnvInitializer.java:63)

Any thoughts?

victor.s.gavrila's picture
Joined: Jan 22 2019 - 6:45am
Last seen: 9 months 2 weeks ago

9 Answers:

1

Most often, this is caused by font jar file not being in the classpath in the jvm in your server.

 

hozawa's picture
52352
Joined: Apr 24 2010 - 4:31pm
Last seen: 5 months 5 days ago
0

I've added the fonts and properties file in my project's resource folder, but still not working.

src -> main -> resources -> jasperreports/font/xxx.xml + ttf fonts

src -> main -> resources -> jasperreports/template.jrxml

src -> main -> resources -> jasperreports_extension.properties

victor.s.gavrila's picture
Joined: Jan 22 2019 - 6:45am
Last seen: 9 months 2 weeks ago
0

Add "jasperreports-fonts-6.0.0.jar" file in your class path. it will work 

update the required Font file in jasperreports-fonts-6.0.0.jar and add Entry in  "jasperreports_extension.properties"

also add entry in fonts.xml . 

 

erstart the server . issue will be solved

vinothm2k's picture
Joined: Dec 16 2018 - 11:20pm
Last seen: 6 months 1 week ago
0

The jasperreports-fonts-6.0.0.jar is part of my application jar now. I didn't update anything in this demo jar. Just made sure that the jrxml file references fonts from this jar

<font fontName="DejaVu Sans" size="14"/>

I get the same exception.

victor.s.gavrila's picture
Joined: Jan 22 2019 - 6:45am
Last seen: 9 months 2 weeks ago
1

have you kept that jar file in server/web-inf/lib folder ?

 

vinothm2k's picture
Joined: Dec 16 2018 - 11:20pm
Last seen: 6 months 1 week ago
0

There was a bug in earlier version 6.x of JasperReports with external fonts that was corrected in later version. Try using the recent version.

hozawa's picture
52352
Joined: Apr 24 2010 - 4:31pm
Last seen: 5 months 5 days ago
0

After some refactoring and testing, I found that the problem was caused by a NPE in the sun.awt.FontConfiguration class. It seems that the font library is looking for libfontconfig1 or the fontconfig.properties file.

The easiest solution was to replace the JDK version in that container from openjdk-8-alpine (which doesn't add the font libraries) with the default debian openjdk-8 version

victor.s.gavrila's picture
Joined: Jan 22 2019 - 6:45am
Last seen: 9 months 2 weeks ago
0

Can you share the latest Jar file related to Fonts,

basically we need pdf file should work without updating Font package in Acrobat Reader DC. 

 

currently we packed "jasperreports-fonts-6.0.0.jar"  with required chinese Fonts (EUDC, Simsun) and deployed in server. 
upon pdf file generation, its probpting in Acrobat Reader to update Font package. we dont want to update the Reader  

vinothm2k's picture
Joined: Dec 16 2018 - 11:20pm
Last seen: 6 months 1 week ago
0

getting Message when trying to open a pdf: 

A font package is required to correctly display this page. Click "OK" to direct your browser to download the add-on from adobe.com. After installation, you will need to close and re-open the document to correctly view contents dependent on these newly installed fonts.
 

vinothm2k's picture
Joined: Dec 16 2018 - 11:20pm
Last seen: 6 months 1 week ago
Feedback
randomness