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

'Arial Unicode MS' is not working whatever it's Chinese or English


shan.cao

Recommended Posts

Hi,

Can anyone help on some chinese character issue on my hand.

I am working on some pdf templates that contain chinese character, I made search and applied this approach, but stil the chinese character is not displaying. 

https://community.jaspersoft.com/wiki/displaying-east-asian-characters-report-pdf-output

ArialUnicodeMS.jar is in my project's classpath which contains ARIALUNI.TTF and I tried net.sf.jasperreport  version 6.4.1,  6.0.0  and 5.1.0, there's no problem for me to compile template and generate pdf.

I debugged with log4j, the jar file ArialUnicodeMS.jar is defintely loaded, actually if I remove the jar from classpath, I would get "net.sf.jasperreports.engine.util.JRFontNotFoundException: Font 'Arial Unicode MS' is not available to the JVM. " error. So I guess the font is registered, but not sure why it's not working.

For simpliticity, below I used a static text for testing, whatever I used  ‘总额’ or unicode  'u603bu989d', even english word "Total", the content in pdf is blank as long as the font is "Arial Unicode MS", if I changed to some other font not registered, like 'STSong', I would fail with this error 

net.sf.jasperreports.engine.JRRuntimeException: Could not load the following font: 
pdfFontName: Helvetica
pdfEncoding: Identity-H
isPdfEmbedded : false

but "Helvetica" is not even used in my jrml file.

<staticText>

    <reportElement x="5" y="185" width="55" height="10" uuid="10ddc6d9-94d3-4dd9-875f-6094eba2c595"/>

    <textElement textAlignment="Left">

        <font fontName="Arial Unicode MS" pdfEncoding="Identity-H" size="8"/>

    </textElement>

    <text><![CDATA[总额]]></text>

</staticText>

Does anyone have any idea about this, thanks!!!

Link to comment
Share on other sites

  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

It is solved.

The root cause is very tricky, but worth to share it here in case someone else met similiar problem.

The issue is simply caused by that the text field is too small to display the content.

Previously, the text is in English 'TOTAL', the font is 'Arial', there's no problem to display it. But after I changed the font to 'Arial Unicode MS', the text field actually is too small to fit in the word. To solve it, just increase the height.

<staticText>

    <reportElement x="5" y="185" width="55" height="14" uuid="10ddc6d9-94d3-4dd9-875f-6094eba2c595"/>

    <textElement textAlignment="Left">

        <font fontName="Arial Unicode MS" pdfEncoding="Identity-H" size="8"/>

    </textElement>

    <text><![CDATA[总额]]></text>

</staticText>

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