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

Fonts in Textfield and Highchart look different when exporting to PDF


detlef.brendle

Recommended Posts

Hi,

I have a custom font "Calibri" that is used on a Highcharts Subtitle element and on a plain text input field.

They look the same in Jasper Studio's preview, but when exporting into PDF they look different.

JasperStudio:

converted-file.png.536f9a80561493d20da303a5485af6ab.png

PDF export:

converted-file.png.2fd3a950d566d8aaf1ce244d83825430.png

It seems that the PDF export has got different letter spacing for highcharts subtitle.

 

Can I control this behaviour somehow ?

Thanks,

Detlef

 

Here is the JRXML:

 

<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="fonts" pageWidth="595" pageHeight="842" whenNoDataType="AllSectionsNoDetail" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="542e8ced-1056-4a71-97d6-c8df4d6d1a32">    <queryString>        <![CDATA[]]>    </queryString>    <title>        <band height="163" splitType="Stretch">            <textField>                <reportElement x="252" y="0" width="136" height="20" uuid="e45daf16-5668-49c8-94c9-9b791208e92d"/>                <textElement>                    <font fontName="Calibri"/>                </textElement>                <textFieldExpression><![CDATA["Text Field(input field)"]]></textFieldExpression>            </textField>            <componentElement>                <reportElement x="100" y="20" width="400" height="130" uuid="b99ed7d3-c9d9-4464-b6ab-9a90c09bd25f"/>                <hc:chart xmlns:hc="http://jaspersoft.com/highcharts" xsi:schemaLocation="http://jaspersoft.com/highcharts http://jaspersoft.com/schema/highcharts.xsd" type="Line" evaluationTime="Report">                    <hc:chartSetting name="default">                        <hc:chartProperty name="title.text" value=""/>                        <hc:chartProperty name="credits.enabled" value="false"/>                        <hc:chartProperty name="credits.href" value=""/>                        <hc:chartProperty name="credits.text" value=""/>                        <hc:chartProperty name="yAxis.title.text" value=""/>                        <hc:chartProperty name="chart.zoomType" value="xy"/>                        <hc:chartProperty name="com.jaspersoft.studio.highcharts.dataconfiguration.simple" value="true"/>                        <hc:chartProperty name="subtitle.text" value="Text Field(subtitle)"/>                        <hc:chartProperty name="subtitle.style.fontFamily" value="Calibri"/>                        <hc:chartProperty name="subtitle.style.fontSize" value="10px"/>                        <hc:chartProperty name="subtitle.style.color" value="#000000"/>                    </hc:chartSetting>                    <multiAxisData>                        <multiAxisDataset/>                        <dataAxis axis="Rows">                            <axisLevel name="Level1">                                <labelExpression><![CDATA["Level Label expression"]]></labelExpression>                                <axisLevelBucket class="java.lang.Comparable">                                    <bucketExpression><![CDATA["Change Me"]]></bucketExpression>                                </axisLevelBucket>                            </axisLevel>                        </dataAxis>                        <multiAxisMeasure name="Measure1" class="java.lang.Number" calculation="Nothing">                            <labelExpression><![CDATA["!MEASURE LABEL!"]]></labelExpression>                            <valueExpression><![CDATA[new Integer(1)]]></valueExpression>                        </multiAxisMeasure>                    </multiAxisData>                </hc:chart>            </componentElement>        </band>    </title></jasperReport>[/code]

 

 

 

Link to comment
Share on other sites

  • Replies 6
  • Created
  • Last Reply

Top Posters In This Topic

Hi,

You need to package up the Calibri font intro a JR font extension. Basically, the font needs to be available to the Java Virtual Machine that runs the JR engine.

Calibri is a Windows font and probably does not exist on the Linux/Unix machine where you run JR Lib and generate the PDF.

You can create font extensions in JSS and it would help you package up the TTF files as JAR files, to add to your application classpath.

I hope this helps.
Teodor

 

Link to comment
Share on other sites

Hi Teodor,

thanks for your answer.

I already create such a jar file and placed it on the classpath.

The fonts are also embedded into the pdf (as far as I can see)

Have you got other ideas?

Thanks,

Detlef

<?xml version="1.0" encoding="UTF-8"?><fontFamilies>    <fontFamily name="Calibri">        <normal><![CDATA[fonts/Calibri/calibri.ttf]]></normal>        <bold><![CDATA[fonts/Calibri/calibrib.ttf]]></bold>        <italic><![CDATA[fonts/Calibri/calibrii.ttf]]></italic>        <boldItalic><![CDATA[fonts/Calibri/calibriz.ttf]]></boldItalic>        <pdfEmbedded><![CDATA[true]]></pdfEmbedded>        <exportFonts/>    </fontFamily>    <fontFamily name="Georgia">        <normal><![CDATA[fonts/Georgia/georgia.ttf]]></normal>        <bold><![CDATA[fonts/Georgia/georgiab.ttf]]></bold>        <italic><![CDATA[fonts/Georgia/georgiai.ttf]]></italic>        <boldItalic><![CDATA[fonts/Georgia/georgiaz.ttf]]></boldItalic>        <pdfEmbedded><![CDATA[true]]></pdfEmbedded>        <exportFonts/>    </fontFamily></fontFamilies>[/code]

 

Link to comment
Share on other sites

Hi Teodor,

 

I investigated a bit further, here my sightings:

- in Jasper server all seems fine - the title of the highcharts component look same than the plain textfield.

- when exporting to PDF things look different:

 

The highcharts component is rendered as image using phantomjs - right ? Seems that phantom is doing something with the font. Do I need to set some properties when rendering using custom fonts ?

 

Thanks,

Detlef

Link to comment
Share on other sites

  • 1 year later...

Hello,

I realize this is an old topic, but it describes exactly the same problem we are having when exporting reports to PDF through our application. The fonts in the body of the report appear fine, but anyplace we use those fonts in a Highchart, it gets replaced with a default font. This is causing display issues with long category names in the axis, etc. All of our fonts are in JAR files and aside from this Highchart issue, we've had great success implementing just about any font we want.

Should this have been fixed by now or no? Is there something different we need to do or set on the server?

Thank you,
Jeff

Link to comment
Share on other sites

Jeff,   Your question about this question would be more visible if it were its own question.  Qreate a new question. Refer to this one if you need to.  A new quetion will be seen by more eyes than one hidden in an answer post on a year old question that has been responded to.

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