Menu

Export PDF with UNICODE and COLUMNS SIZE

2007-02-09
2012-10-09
  • Tran Huu Tai

    Tran Huu Tai - 2007-02-09
    • Unicode characters were not display correctly When I tried to export table to PDF (Using displaytag-1.1) which contain unicode characters.

    • And the column width is not correct when we export. It's seam to be divide the column size equally between columns??? why?

     
    • Giorgos Saslis

      Giorgos Saslis - 2007-02-23

      The problem is the font used. First you need to make sure you have unicode truetype fonts on your computer, (I'm running opensuse 10.2 and had to do an online update and manually select to download the MS TT fonts). Then you have to download and alter the displaytag source (or create a new class that extends the one in the displaytag source and override the appropriate methods) by changing the font, wherever it's used in your exporter class, to one that supports BaseFont.IDENTITY_H. I got it to work by changing

      smallFont = FontFactory.getFont(FontFactory.HELVETICA, 7, Font.NORMAL, new Color(0, 0, 0));

      to:

      smallFont = FontFactory.getFont("ComicSansMS", BaseFont.IDENTITY_H, 10, Font.NORMAL, new Color(0x00, 0x00, 0x00));

      (after I first registered these new fonts with the FontFactory class, by doing:

      FontFactory.register("/usr/share/fonts/truetype/comic.ttf");

      .. Hope this helps..

       

Log in to post a comment.