我想在java web应用程序中使用iText(版本5.4.0)创建pdf文档,并且遇到了字体问题。itext字体UnsupportedCharsetException
Web应用程序是多语言的,因此用户可以用各种语言(例如英语,法语,立陶宛语,中文,日语,阿拉伯语等)将信息保存到系统中。
当我尝试配置pdf输出一些日文文本样本时,它没有显示出来,所以我开始在官方的“iText in Action”书中遵循这些例子。我所遇到的问题是,当我尝试并配置BaseFont.IDENTITY_H编码的字体我得到以下错误:在书中
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或谷歌搜索中提到这个问题。
对我可能错过了什么有任何建议?
你使用* .afm fornts或* .ttf吗? – mkl 2013-03-24 22:24:43
到目前为止,我刚刚指定了时间roman: BaseFont baseFont = BaseFont.createFont(BaseFont.TIMES_ROMAN,“UTF-8”,/*BaseFont.IDENTITY_H,*/ BaseFont.EMBEDDED); – 2013-03-25 09:43:21
是不是罗马标准的14种字体之一?身份编码仅对嵌入字体有意义。 – mkl 2013-03-25 15:19:20