Jump to content

How to display Arabic language fonts in pdf reports using Jasper(iReport) designer


satishmhiremath

Recommended Posts

Hi Team,

As I tried using unicode with  

properties as UTF-8, Font Name DejaVu Sans, pdfEmbedded=true, pdf encoding=cp1256(Arabic) , installing Dejavu Sans.ttf  file

as below for displaying Arabic text in Jasper tool as text field expression

($F{state.locale}.equalsIgnoreCase("AR") || $F{state.locale}.equalsIgnoreCase("ar-EG")) ? "\u0627\u0633\u0645 \u0627\u0644\u0645\u0646\u062A\u062C" :"Product Name"

But the result in pdf is not displaying in arabic.

It displays the same Hadcoded Unicode \u0627\u0633\u0645 \u0627\u0644\u0645\u0646\u062A\u062C

or

?????????

Kindly do the needfull to display Arabic text fonts ASAP.

 

Regards,

Satish M Hiremath

Link to comment
Share on other sites

  • Replies 5
  • Created
  • Last Reply

Top Posters In This Topic

After all workarounds, i am able to fix this issue in Jasper ireport as follows

In Text Properties of jrxml:

Font Name : Arial

Pdf Font Name : ../arial.ttf

Pdf Embedded : true

Pdf Encoding : Identity-H

-------------------------------------------------------

In your Project META-INF folder

Create and Add reports folder containing arial.ttf files and font.xml

Outside META-INF folder, add jasper-extensions.properties file

So finally,  

jasper-extensions.properties --- Uses --- fonts.xml --- Uses --- true type font files   

jasper-extensions.properties file --> fonts.xml ---> arial.ttf 

The syntactical contents of

Font.xml:

<?xml version="1.0" encoding="UTF-8"?>
   <fontFamilies>
<fontFamily name="Arial">
       <normal><![CDATA[META-INF/reports/fonts/arial.ttf]]></normal>
       <bold><![CDATA[META-INF/reports/fonts/arialbd.ttf]]></bold>
       <italic><![CDATA[META-INF/reports/fonts/ariali.ttf]]></italic>
       <boldItalic><![CDATA[META-INF/reports/fonts/arialbi.ttf]]></boldItalic>
       <pdfEmbedded><![CDATA[true]]></pdfEmbedded>
   </fontFamily>
</fontFamilies>

jasper-extensions.properties :

net.sf.jasperreports.extension.registry.factory.fonts=net.sf.jasperreports.engine.fonts.SimpleFontExtensionsRegistryFactory
net.sf.jasperreports.extension.simple.font.families.myfamily=META-INF/fonts.xml

 

Regards,

Satish M Hiremath

Link to comment
Share on other sites

  • 6 years later...

In your Project META-INF folder

Create and Add reports folder containing arial.ttf files and font.xml

Outside META-INF folder, add jasper-extensions.properties file

So finally,  

jasper-extensions.properties --- Uses --- fonts.xml --- Uses --- true type font files   

jasper-extensions.properties file --> fonts.xml ---> arial.ttf 

The syntactical contents of

Font.xml:

<?xml version="1.0" encoding="UTF-8"?>

   <fontFamilies>

<fontFamily name="Arial">

       <normal><![CDATA[META-INF/reports/fonts/arial.ttf]]></normal>

       <bold><![CDATA[META-INF/reports/fonts/arialbd.ttf]]></bold>

       <italic><![CDATA[META-INF/reports/fonts/ariali.ttf]]></italic>

       <boldItalic><![CDATA[META-INF/reports/fonts/arialbi.ttf]]></boldItalic>

       <pdfEmbedded><![CDATA[true]]></pdfEmbedded>

   </fontFamily>

</fontFamilies>

jasper-extensions.properties :

net.sf.jasperreports.extension.registry.factory.fonts=net.sf.jasperreports.engine.fonts.SimpleFontExtensionsRegistryFactory

net.sf.jasperreports.extension.simple.font.families.myfamily=META-INF/fonts.xml

I didn't get this 

 

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