今天做了個iText的小例子,結果在輸出中文時報錯了,iTextAsian.jar包也加了呀。
報錯如下:
com.itextpdf.text.DocumentException: Font 'STSong-Light' with 'UniGB-UCS2-H' is not recognized.
at com.itextpdf.text.pdf.BaseFont.createFont(BaseFont.java:699)
at com.itextpdf.text.pdf.BaseFont.createFont(BaseFont.java:606)
at com.itextpdf.text.pdf.BaseFont.createFont(BaseFont.java:441)
at com.syax.itext.FirstPDF4.main(FirstPDF4.java:43)
出錯Java程式碼 BaseFont bf = BaseFont.createFont( "STSong-Light" , "UniGB-UCS2-H" , BaseFont.NOT_EMBEDDED); google一下,處理方式可以採用windos自帶字型檔: 解決Java程式碼 BaseFont bf = BaseFont.CreateFont( "c://windows//fonts//simsun.ttc,1" , BaseFont.IDENTITY_H, BaseFont.EMBEDDED); ———————————————
轉載:iText中文,報錯解決_com.itextpdf.text.documentexception: the original -CSDN部落格