7 Replies Latest reply: May 31, 2011 12:19 AM by handat RSS

    display Chinese character in iText

    Hjava
      hi all I need to display Chinese character in my pdf file
      I have iTextAsian.jar on my libraries , but the Chinese character did not show up

      nested1.addCell(new Phrase(chinessname));
        • 1. Re: display Chinese character in iText
          865172
          The best way is to embed font in your generated PDF as iText documentation shows (example of writing chinese characters to PDF) :
          http://itextpdf.com/examples/iia.php?id=158
          • 2. Re: display Chinese character in iText
            Hjava
            Thank You!
            I also saw this example, but I don't get what is c:/windows/fonts/arialuni.ttf
            BaseFont unicode =
            BaseFont.createFont("c:/windows/fonts/arialuni.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED)
            • 3. Re: display Chinese character in iText
              865172
              I have it:

              C:\>cd WINDOWS\Fonts

              C:\WINDOWS\Fonts>dir ARIALUNI.TTF
              El volumen de la unidad C es Sistema
              El número de serie del volumen es: A0FB-F675

              Directorio de C:\WINDOWS\Fonts

              18/11/2002 18:44 23.275.812 ARIALUNI.TTF
              1 archivos 23.275.812 bytes
              0 dirs 33.009.053.696 bytes libres
              • 4. Re: display Chinese character in iText
                Hjava
                But I don't use Window I use solaris
                doesn't this kind of think suppose system independent ????

                Edited by: Hjava on May 30, 2011 6:27 PM
                • 5. Re: display Chinese character in iText
                  handat
                  You need to embed a font file. TTF files are system independent, but not all system have them installed by default. The sample just showed you the most commonly used font file on Windows. You will need to have some font file located somewhere on your system and point the code at that location for it to embed the font.

                  The following link shows you how you can make a TTF font like freetype if you don't have any font files:

                  http://developers.sun.com/dev/gadc/techtips/adding_fonts.html

                  Or you can just copy one from another system.
                  • 6. Re: display Chinese character in iText
                    Hjava
                    I download freetype-2.1.10,
                    and I get ./configure --enable-static
                    ./configure: make: not found
                    how to continue ... inorder to create your owner font

                    by the way I download the new extrajars-2.1.zip, this new jar supporting Chinese characters . but my first font is not working second font is work fine I don't know why?
                    first one
                    BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED); not working
                    //second one
                    BaseFont bfChinese= BaseFont.createFont("MSungStd-Light", "UniCNS-UCS2-H", BaseFont.NOT_EMBEDDED);

                    Thank you!
                    • 7. Re: display Chinese character in iText
                      handat
                      and I get ./configure --enable-static
                      ./configure: make: not found
                      This requires a C compiler and its associated tools. You will need to install one if you want to compile it.


                      The UniGB-UCS2-H is for simplified Chinese while UniCNS-UCS2-H is for traditional Chinese. Your system is probably setup for traditional Chinese but you should be able to configure your system to do either. You might just need to install the appropriate Locale.