pdf格式的发票转图片出现中文乱码

报错如下:
2019-12-26 10:26:24.520 - WARN 11975 [ XNIO-2 task-14] o.a.pdfbox.pdmodel.font.PDCIDFontType0   : Using fallback UnDotum for CID-keyed font AdobeKaitiStd-Regular
2019-12-26 10:26:24.521 - WARN 11975 [ XNIO-2 task-14] o.a.pdfbox.rendering.CIDType0Glyph2D     : No glyph for 3530 (CID 0dca) in font AdobeKaitiStd-Regular
2019-12-26 10:26:24.522 - WARN 11975 [ XNIO-2 task-14] o.a.pdfbox.rendering.CIDType0Glyph2D     : No glyph for 4532 (CID 11b4) in font AdobeKaitiStd-Regular
2019-12-26 10:26:24.522 - WARN 11975 [ XNIO-2 task-14] o.a.pdfbox.rendering.CIDType0Glyph2D     : No glyph for 3493 (CID 0da5) in font AdobeKaitiStd-Regular
2019-12-26 10:26:24.522 - WARN 11975 [ XNIO-2 task-14] o.a.pdfbox.rendering.CIDType0Glyph2D     : No glyph for 1480 (CID 05c8) in font AdobeKaitiStd-Regular
2019-12-26 10:26:24.523 - WARN 11975 [ XNIO-2 task-14] o.a.pdfbox.rendering.CIDType0Glyph2D     : No glyph for 1599 (CID 063f) in font AdobeKaitiStd-Regular
2019-12-26 10:26:24.524 - WARN 11975 [ XNIO-2 task-14] o.a.pdfbox.rendering.CIDType0Glyph2D     : No glyph for 2706 (CID 0a92) in font AdobeKaitiStd-Regular
2019-12-26 10:26:24.524 - WARN 11975 [ XNIO-2 task-14] o.a.pdfbox.rendering.CIDType0Glyph2D     : No glyph for 3189 (CID 0c75) in font AdobeKaitiStd-Regular
2019-12-26 10:26:24.524 - WARN 11975 [ XNIO-2 task-14] o.a.pdfbox.rendering.CIDType0Glyph2D     : No glyph for 2058 (CID 080a) in font AdobeKaitiStd-Regular
2019-12-26 10:26:24.525 - WARN 11975 [ XNIO-2 task-14] o.a.pdfbox.rendering.CIDType0Glyph2D     : No glyph for 4235 (CID 108b) in font AdobeKaitiStd-Regular
2019-12-26 10:26:24.525 - WARN 11975 [ XNIO-2 task-14] o.a.pdfbox.rendering.CIDType0Glyph2D     : No glyph for 2488 (CID 09b8) in font AdobeKaitiStd-Regular
2019-12-26 10:26:24.525 - WARN 11975 [ XNIO-2 task-14] o.a.pdfbox.rendering.CIDType0Glyph2D     : No glyph for 3840 (CID 0f00) in font AdobeKaitiStd-Regular
2019-12-26 10:26:24.526 - WARN 11975 [ XNIO-2 task-14] o.a.pdfbox.rendering.CIDType0Glyph2D     : No glyph for 1259 (CID 04eb) in font AdobeKaitiStd-Regular


2019-12-26 10:26:24.547 - WARN 11975 [ XNIO-2 task-14] o.a.pdfbox.pdmodel.font.PDCIDFontType0   : Using fallback AdobeSongStd-Light for CID-keyed font STSong-Light

 

 


 

 

 

pdf文件的中文字体是STSong-Light,服务器字体库中没有这个字体,转图片的时候一直在用其他字体替代。告警日志分析不出到底是缺少哪个字体导致的乱码。所以最终的解决方法是把告警日志里涉及到的字体逐一添加,STSong-Light字体网上无资源,此时不用纠结,因为参考其他人遇到同类问题的解决方案,用替代字体完全可行。AdobeSongStd-Light加完无效,AdobeKaitiStd-Regular加完乱码问题解决。转化的图片中的中文字体用的就是AdobeKaitiStd-Regular。

最后附上linux添加字体的方法:

#cd /usr/share/fonts/ // 进入系统自带的字体目录

#mkdir myfonts // myfonts 是你自己随便取得文件夹名字,一定要有这一步

#将字体文件拷贝到这个文件夹下,在cd /usr/share/fonts/目录下执行以下命令

#mkfontscale

#mkfontdir

#fc-cache -fv //更新字体缓存

#fc-list | grep Ad// 查看系统中所有得字体,可用于测试是否安装字体成功。

注意,字体安装成功后,需要重启自己的应用服务。
 

 

你可能感兴趣的:(pdf格式的发票转图片出现中文乱码)