itext字体UnsupportedCharsetException [英] itext font UnsupportedCharsetException
问题描述
网页应用程序是多语言的,所以用户可以用各种语言(例如英语,法语,立陶宛语,中文,日语,阿拉伯语等)将信息保存到系统中。
<当我试图配置pdf输出一些日本文本样本没有出现,所以我开始在官方iText在行动书中的例子。我遇到的问题是,当我尝试使用BaseFont.IDENTITY_H编码配置字体时,出现以下错误:
java .nio.charset.UnsupportedCharsetException:Identity-H
位于java.nio.charset.Charset.forName(Charset.java:505)
位于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)
没有任何内容或搜索Google提到这个问题。
对于我可能错过的任何建议?
正如你可能从两个Michaels的答案中理解的那样,你错误的假设了标准的Type 1字体Times Roman和
IDENTITY_H
是兼容的。如果要使用 IDENTITY_H
,则必须更改字体,或者如果要使用标准Type 1字体(在这种情况下使用 BaseFont.EMBEDDED
没有意义,因为标准的Type 1字体永远不会嵌入)。对不起,如果我没有在我的书中提到这一点。我认为这是微不足道的。可以从我写的复合字体中扣除它。 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?
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.
这篇关于itext字体UnsupportedCharsetException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!