Search code examples
javafontsitextcjk

Using iTextpdf version 5.5 and itext-asian 5.2 kanji charachter 𠮷 is not displaying on PDF


Creating PDF using

  • iTextpdf version 5.5.13.3
  • itext-asian 5.2.0

Only kanji character 𠮷 is not displayed, but all other Japanese characters are displayed on created PDF.

Code

Used to set the BaseFont

BaseFont bfJapanese = BaseFont.createFont(
  AsianFontMapper.JapaneseFont_Min,
  AsianFontMapper.JapaneseEncoding_H,
  BaseFont.NOT_EMBEDDED
);

Is there any other way to set the Japanese fonts?


Solution

  • Creating a font by name and encoding

    You called the method BaseFont.createFont(String name, String encoding, boolean embedded) correctly.

    The AsianFontMapper class has those constants for 2 font names and 4 encodings:

    // font names
        public static final String JapaneseFont_Go = "HeiseiKakuGo-W5";
        public static final String JapaneseFont_Min = "HeiseiMin-W3";
    // encodings
        public static final String JapaneseEncoding_H = "UniJIS-UCS2-H";
        public static final String JapaneseEncoding_V = "UniJIS-UCS2-V";
        public static final String JapaneseEncoding_HW_H = "UniJIS-UCS2-HW-H";
        public static final String JapaneseEncoding_HW_V = "UniJIS-UCS2-HW-V";
    

    The Kanji character 𠮷 for "earth" should be supported by above Japanese fonts of Heisei family and all of those encodings.

    Japanese font must be present on your system

    Make sure that they are available the system creating and viewing the PDF.

    When using embedded = false to keep the PDF-size small, they must also been present on the viewing system.

    See Wikipedia article: List of CJK fonts, especially the table for Japanese: