Monday, February 3, 2014

Setting TrueType fonts location for BIRT PDF report

When using TrueType fonts for PDF in BIRT report engine, you may see that some fonts like barcode or fonts for international languages are not appear correctly in PDF format report.

BIRT report engine is responsible for rendering exported format like PDF. It has configuration file for setting location of PDF fonts depend on you are running report in Eclipse BIRT designer or your java application.

If your report is run in BIRT designer, report engine will read configuration from fontsConfig.xml file under

     /eclipse_install_dir/plugins/org.eclipse.birt.report.engine.fonts_x.x.x.x

Open the file and look for <font-paths> section. Make sure you add your TrueType font location in the list.

For example TrueType fonts for thai language in Ubuntu linux are located in tlwg sub folder.

     <path path="/usr/share/fonts/truetype/tlwg"/>

But if your report is run in your java application that use BIRT report runtime engine in the form of libraries (jar files). The file fontsConfig.xml is packaged in

     org.eclipse.birt.runtime_4.3.1.xxxxxx.jar

Unfortunately, this file is signed and modifying the content of this file cause security exception in runtime. How I can fix this problem is to create symbolic link to the fonts (used in report) in the directory listed in original fontsConfig.xml

Case study
I use Ubuntu 12.04-TLS  and I want to use my Thai fonts in BIRT report with PDF format. I found that thai fonts are in

     /usr/share/fonts/truetype/tlwg

but it is not exists in fontsConfig.xml (in birt runtime jar file) . After checking the list of path in fontsConfig.xml, I've found the similar one.

     /usr/share/fonts/truetype/

The solution is creating symbolic link in this directory to target fonts. Assume wanted fonts is Norasi.ttf is in /usr/share/fonts/truetype/tlwg/.

     # cd /usr/share/fonts/truetype/
     # ln -s /usr/share/fonts/truetype/tlwg/Norasi.ttf    Norasi.ttf

After creating symbolic link, report engine should see this font and render report correctly.





1 comment:

  1. Hi
    I am facing same issue with pdf generated by birt report . I want languages like Japanese , Hindi , Chinese , Bengali and other languages to display in pdf I verified in database but in database everything is fine but while displaying in the pdf format some characters are missing for Japanese language and other languages empty characters are displaying. HTML format everything is working as expected but I am facing issue with pdf only.
    I did all changes as above motioned but there is no use. Can someone please me in this.
    Thanks in advance

    ReplyDelete