0

For my web project, I use itextpdf 5.5.4. I have a HTML table with Chinese characters. Here is how the table is displayed in PDF:

Strint tableString = a_string_of_HTML_table_with_Chinese_chaacters;
XMLParser parser = new XMLParser(xmLWorker);
parser.parse(new ByteArrayInputStream(tableString.getBytes("UTF-8")));

With the above code, Chinese character 月 (which means month in English) is displayed as 月 in PDF.

In Eclipse (the IDE), I am able to see Chinese characters display correctly in tableString. I tried the parse method with different signatures, but with no success. I cannot upgrade to use the latest version of itextpdf due to various project reasons.

halfer
  • 19,824
  • 17
  • 99
  • 186
curious1
  • 14,155
  • 37
  • 130
  • 231
  • 1. You didn't read the documentation. If you want Chinese characters, you need to define a `FontProvider` and provide a Chinese font. Since you don't do that, it is **obvious** that no Chinese is rendered. 2. You are using an old iText version. **You should upgrade** and read the [HTML to PDF tutorial](https://developers.itextpdf.com/content/itext-7-converting-html-pdf-pdfhtml), and take a look at the [language FAQ entry](https://developers.itextpdf.com/content/itext-7-converting-html-pdf-pdfhtml/chapter-7-frequently-asked-questions-about-pdfhtml/which-languages-are-supported-pdfhtml). – Bruno Lowagie Apr 03 '18 at 18:28
  • I closed the question with an iText 5 answer that renders Chinese characters. Please only use this example if you want to make it difficult for yourself. If you want to make it easy for yourself, upgrade to iText 7. Also note that support for iText 5 is being discontinued, so if you create a project for your customer, your customer won't get any support. Who is your customer? – Bruno Lowagie Apr 03 '18 at 18:32

0 Answers0