Arabic text is not displaying when exporting pdf using jasper reports 5.6 library

0
After googling a lot I found somewhere that the arabic text is working in pdf if we set following attribute-:
pdfFontName:Arial,
pdfEncoding:Identity-H,
isPdfEmbedded:true
 
These attributes can be set in using jasperSoft Studio or by Java code. I have tried both but it throws following error:-
net.sf.jasperreports.engine.JRRuntimeException: Could not load the following font : 
pdfFontName   : Arial
pdfEncoding   : Identity-H
isPdfEmbedded : true
 
This works fine when I am using Helvetica/Courier/Times-Roman as the pdfFontName. Thus I am suspecting that the libraries are not getting Arial font
wherever it is looking for pdfFontName. Where should I provide the arial font to make it work. Any help will be appreciated.
sanjayjha9950's picture
Joined: Dec 22 2016 - 4:04am
Last seen: 3 years 1 month ago

2 Answers:

0
hozawa's picture
57710
Joined: Apr 24 2010 - 4:31pm
Last seen: 8 months 1 week ago
0

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

satishmhiremath's picture
Joined: Sep 29 2016 - 7:06am
Last seen: 2 years 5 months ago
Feedback
randomness