Can't get Japanese characters to display in a form
I have recently purchased the book and am doing very lite iText work. All I am doing is reading in an existing PDF document that has fields. Then I fill those fields with text supplied by my application. This works just fine with English text.
I am referencing itextpdf-5.3.0.jar, text-xtra-5.3.0.jar, and itextasian-1.5.2.jar
Here's the issue I am seeing:
1. I am developing on the Mac (OS X Lion)
2. When the field text is English or Japanese (I suspect same will happen for an CJK language) I am seeing the field text in the preview just fine.
3. When the PDF file is transferred to Windows and previewed using Acrobat Reader, the Japanese text disappears. English fields show up fine.
4. Here's the code I am using to update the document (try/catch and close() calls omitted):
PdfReader reader = new PdfReader(pdfFilename);
PdfStamper stamper = new PdfStamper(reader, new FileOutputStream(updatedPdfFilePath));
final AcroFields stamperFields = stamper.getAcroFields();
for (String key : this.fields.keySet())
if (stamperFields.getFieldItem(key) != null)
String value = this.fields.get(key);
5. I suspect it has to do with the fact that Japanese font is not embedded in the document and Acrobat on Windows can't find the proper font to display.
6. I read the section on fonts (admittedly I am a total newbie when it comes to fonts) and have tried a view things.
7. When I add this code before the above code, the preview on the Mac goes totally blank:
BaseFont unicode = BaseFont.createFont("HeiseiMin-W3", "UniJIS-UCS2-H", BaseFont.NOT_EMBEDDED);
8. I also tried this call, but then Japanese text doesn't show up on the Mac preview either:
Please help! Thanks in advance!