InetSoft Product Information: Generating PDF Reports in Chinese-Japanese-Korean

The original PDF specification was designed to create documents with 8 bit characters. Since the Chinese-Japanese-Korean (CJK) characters are 16 bits, they did not fit well in a PDF document. The PDF 1.3 specification (equivalent to Acrobat 4.0 and higher) added support for CID fonts. The CID fonts are designed specifically to handle fonts with a large character set and are capable of using 16-bit character encoding.

The PDF generation in Style Intelligence supports CID fonts with two new classes: PDF4Printer and PDF4Generator. They correspond to the PDF3Printer and PDF3Generator. Because these two classes generate PDF documents according to PDF 1.3 specification, the output can only be viewed using Acrobat 4.0 and higher.

Report Tool Demo Register

Font Installation and Text Insertion

To generate documents with CJK fonts, the Adobe Acrobat Asian Language Pack must be installed on the machine. You can choose to install one or all of the three languages supported by the pack: Chinese, Japanese and Korean. The language pack installs CID fonts for each of the selected languages.

CID fonts use the same format as TrueType fonts. However, the internal tables in the fonts are slightly different from regular TrueType fonts. Therefore, the CID fonts installed by the language pack cannot be used in Java (or OS) as regular fonts. In order to create a CJK document, a regular TrueType font also needs to be installed on the machine for the language. We will use Japanese as the example font in the following discussions. Chinese and Korean fonts are handled in the same way.

To create a document containing Japanese characters, first select the correct Japanese TrueType font (OS font) for the report element:

 // "MS Mincho" is a TrueType Japanese font
 report.setCurrentFont(new Font("MS Mincho", Font.PLAIN, 8)); 

Then we can insert the Japanese text into the report using the same StyleSheet API:

layout.addText("This is a Japanese character: \u1083"); 

If the report is created from a report template, the Japanese characters can be entered in the Designer and saved in the template file. The template file uses UTF8 encoding for text values and can handle all unicode characters correctly.

view demo icon
View a 2-minute demonstration of InetSoft's easy, agile, and robust BI software.

Create PDF4Printer or PDF4Generator

After the report is created, it can be viewed using the Previewer as usual. To generate the PDF document from the report, we first create a PDF4Printer (or PDF4Generator, which handles PDF bookmarks described earlier).

FileOutputStream output = new FileOutputStream("output.pdf");
PDF4Printer pdf = new PDF4Printer(output);
pdf.putFontName("MS Mincho", "HeiseiMin-W3-Acro");
Previous: PDF Report Generation