Jump to content
Changes to the Jaspersoft community edition download ×

font issue with jasperreport 5.2 vs jasperreport 5.5


d.artini

Recommended Posts

Hi,

i'am using jasperport engine with font extensions to generate a pdf file

for example: i'have done an Arial.jar from iReport and put it into the CLASSPATH.

 

than to generate the pdf i use an own small java class (from command line) with arguments:

- Data source (xml)

- File. Jasper report

- Name of the pdf

and pass them to the jasperreport engine

 

now with jasperreport 5.2 it works fine   (even in version 5.0 works fine)

while in the version 5.5 i get this error:

net.sf.jasperreports.engine.util.JRFontNotFoundException: Font 'Arial' is not available to the JVM. See the Javadoc for more details.

        at net.sf.jasperreports.engine.fonts.FontUtil.checkAwtFont(FontUtil.java:347)

        at net.sf.jasperreports.engine.fonts.FontUtil.getAwtFontFromBundles(FontUtil.java:295)

        at net.sf.jasperreports.engine.fill.SimpleTextLineWrapper.loadFont(SimpleTextLineWrapper.java:365)

        at net.sf.jasperreports.engine.fill.SimpleTextLineWrapper.getGeneralFontInfo(SimpleTextLineWrapper.java:339)

        at net.sf.jasperreports.engine.fill.SimpleTextLineWrapper.createFontInfo(SimpleTextLineWrapper.java:279)

        at net.sf.jasperreports.engine.fill.SimpleTextLineWrapper.start(SimpleTextLineWrapper.java:241)

        at net.sf.jasperreports.engine.fill.TextMeasurer.measure(TextMeasurer.java:411)

        at net.sf.jasperreports.engine.fill.JRFillTextElement.chopTextElement(JRFillTextElement.java:621)

        at net.sf.jasperreports.engine.fill.JRFillStaticText.prepare(JRFillStaticText.java:187)

        at net.sf.jasperreports.engine.fill.JRFillElementContainer.prepareElements(JRFillElementContainer.java:331)

        at net.sf.jasperreports.engine.fill.JRFillBand.fill(JRFillBand.java:384)

        at net.sf.jasperreports.engine.fill.JRFillBand.fill(JRFillBand.java:358)

        at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillColumnBand(JRVerticalFiller.java:2059)

        at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillGroupHeader(JRVerticalFiller.java:639)

        at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillGroupHeaders(JRVerticalFiller.java:561)

        at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReportStart(JRVerticalFiller.java:286)

        at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:151)

        at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:932)

        at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:864)

        at net.sf.jasperreports.engine.fill.JRFiller.fill(JRFiller.java:114)

        at net.sf.jasperreports.engine.JasperFillManager.fill(JasperFillManager.java:653)

        at net.sf.jasperreports.engine.JasperFillManager.fill(JasperFillManager.java:569)

        at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:915)

 


 

why

there is some difference between the two version

about the fonts ?

 

many thanks

Daniele

Link to comment
Share on other sites

  • Replies 6
  • Created
  • Last Reply

Top Posters In This Topic

  • 1 month later...

As Jaspersoft doesn't seem interested in answering this, even though it is clearly a bug within their software, I'll do my best to let people know what I've found with this and what i've managed to do to get it working (in my environment at least).

The crux of the problem appears to be that Jaspersoft Server 5.5 doesn't read the parameters for the font extensions if the values are enclosed in CDATA elements in their XML files. 5.2 did.

iReport (version 5.2 and 5.5) produces JAR archives that contain XML files with the parameter values enclodes in CDATA blocks.

Jaspersoft Studio 5.5 does not enclose values in CDATA blocks, however it has a different bug where it uses the absolute path to the font file on the local machine where the JAR font extension was created, instead of the relative path to the font file contained within the JAR archive.

Jaspersoft Studio 5.2 doesn't appear to be capable of creating a working JAR font extension at all.

In order to fix this you can edit the XML file within the JAR archive of the font extension (Hopefully you don't have too many font extensions...)

You can open the JAR archive using 7-Zip or soething similar, in there under the fonts directory, there'll be an XML file that needs to be modified (either using the in-built editor of your compression program or by extracting, editing, saving and replacing the file within the archive).

The contents of this file should look something like this (this is the file generated by iReport, which you should be working with, as Jaspersoft Studio doesn't, well, work properly at all) -

<?xml version="1.0" encoding="UTF-8"?><fontFamilies>   <fontFamily name="Herr Von Muellerhoff">       <normal><![CDATA[fonts/HerrVonMuellerhoff-Regular.ttf]]></normal>       <pdfEmbedded><![CDATA[true]]></pdfEmbedded>   </fontFamily></fontFamilies>[/code]

What you need to do, for each of the properties listed, is remove the surrounding CDATA blocks (so, "<![CDATA[" at the beginning and "]]>" at the end. The resulting file should look similar to this -

<?xml version="1.0" encoding="UTF-8"?><fontFamilies>   <fontFamily name="Herr Von Muellerhoff">       <normal>fonts/HerrVonMuellerhoff-Regular.ttf</normal>       <pdfEmbedded>true</pdfEmbedded>   </fontFamily></fontFamilies>[/code]

Save that file in place within the JAR archive and upload to you lib directory on the server (replacing the current font extension), and that should get you up and running again. At least it did for me.

Link to comment
Share on other sites

  • 1 month later...
  • 3 weeks later...
  • 4 months later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...