itext font UnsupportedCharsetException
character-encoding, fonts, itext, java
Solution
As you probably understood from the answers from two Michaels, you made the wrong assumption that the standard Type 1 font Times Roman and `IDENTITY_H` are compatible. You'll have to change the font if you want to use `IDENTITY_H`, or change the encoding if you want to use a standard Type 1 font (in which case using `BaseFont.EMBEDDED` doesn't make sense because standard Type 1 fonts are never embedded). I'm sorry if I didn't mention this in my book. I thought it was kind of trivial. One can deduct it from what I wrote about composite fonts.
Problem
I am trying to create pdf documents using iText (version 5.4.0) in a java web application and I have come across an issue with fonts. The web application is multi-lingual, and so users may save information into the system in various languages (eg. english, french, lithuanian, chinese, japanese, arabic, etc.). When I tried to configure the pdf to output some sample japanese text it didn't show up, so I started following the examples in the official "iText in Action" book. The problem I have encountered is that when I try and configure a font with BaseFont.IDENTITY_H encoding I get the following error: ``` java.nio.charset.UnsupportedCharsetException: Identity-H at java.nio.charset.Charset.forName(Charset.java:505) at com.itextpdf.text.pdf.PdfEncodings.convertToBytes(PdfEncodings.java:186) at com.itextpdf.text.pdf.Type1Font.<init>(Type1Font.java:276) at com.itextpdf.text.pdf.BaseFont.createFont(BaseFont.java:692) at com.itextpdf.text.pdf.BaseFont.createFont(BaseFont.java:615) at com.itextpdf.text.pdf.BaseFont.createFont(BaseFont.java:450) ``` Nothing in the book or searching Google mentions this issue. Any suggestions as to what I might have missed?