Jump to content
We've recently updated our Privacy Statement, available here ×

Jasper font extension working only for PDF but not for other formats (HTML,XLS,DOC)


joan160096

Recommended Posts

Through Jaspersoft Studio we exported the built-in Windows Calibri font variants for use in a webapp into a font extension JAR, using the following settings:

Dcmw9bv.png

YL1snar.png

The directory structure within the exported jrfontextensions.jar is as follows:

--jrfontextensions  --jasperreports_extension.properties  --fonts    --fontsfamily1505796949749.xml    --Custom_Font      --calibri.ttf      --calibrib.ttf      --calibrii.ttf      --calibriz.ttf[/code]

Contents of jasperreports_extension.properties:

net.sf.jasperreports.extension.registry.factory.fonts=net.sf.jasperreports.engine.fonts.SimpleFontExtensionsRegistryFactorynet.sf.jasperreports.extension.simple.font.families.ireportfamily1505796949749=fonts/fontsfamily1505796949749.xml[/code]

Contents of fontsfamily1505796949749.xml:

<?xml version="1.0" encoding="UTF-8"?><fontFamilies>    <fontFamily name="Custom-Font">        <normal><![CDATA[fonts/Custom_Font/calibri.ttf]]></normal>        <bold><![CDATA[fonts/Custom_Font/calibrib.ttf]]></bold>        <italic><![CDATA[fonts/Custom_Font/calibrii.ttf]]></italic>        <boldItalic><![CDATA[fonts/Custom_Font/calibriz.ttf]]></boldItalic>        <pdfEncoding><![CDATA[identity-H]]></pdfEncoding>        <pdfEmbedded><![CDATA[true]]></pdfEmbedded>        <exportFonts>            <export key="html"><![CDATA[Custom-Font]]></export>            <export key="rtf"><![CDATA[Custom-Font]]></export>            <export key="xhtml"><![CDATA[Custom-Font]]></export>        </exportFonts>    </fontFamily></fontFamilies>[/code]

We then use the custom font on our JRXML templates similar to this way:

hapaVvT.png

Now when we export this report as PDF, the Calibri font embedded into the PDF as the Custom-Font displays correctly, as expected:

955QuOk.png

But we ran into problems when trying to export the report to other formats like HTML, DOC, and XLS. It seems the web browser or office apps don't recognize the "Custom-Font" and falls back to one of their default fonts: the XLS report defaults to DejaVu Sans, while the HTML and DOC reports default to Times New Roman.5GFbyw2 (I can provide additional screencaps of these reports if you want)

I feel like we must be missing something obvious here, perhaps we're lacking a jasperreports.properties file, or some JRExporter configuration?OTnG87j Thanks for any repsponse.

Link to comment
Share on other sites

  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Also forgot to ask - and sorry if this is a stupid question - but are jasper font extensions intended for PDF-exported reports only? Never seen it explicitly stated that way but that's the impression that I'm getting from the online tutorials and articles I've read so far.

Link to comment
Share on other sites

Here are the additional screencaps of the defective reports.


XLS - defaults to DejaVu Sans - granted it highly resembles Calibri, but it's still clearly different. Notice how the tail of the lowercase 't' curves up for Calibri in the PDF (correct) but not for DejaVu Sans in the XLS (incorrect):

OTnG87j.png


DOC

x4KBhms.png


HTML

5GFbyw2.png

Link to comment
Share on other sites

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...