openoffice中文乱码
问题分析
linux下通过 openoffice 和 jodconverter,进行word转换为pdf时,不出意外会出现 "中文乱码" 问题。
并非是程序的问题,是linux系统字体的问题,解决方法也很简单:
给linux扩展中文字体(需重启openoffice)即可
linux下,字体配置文件(不清楚是否准确):
/etc/fonts/fonts.conf
查看文件,可查看有3行,这个是加载字体文件的目录:
<dir>/usr/share/fonts</dir>
<dir>/usr/share/X11/fonts/Type1</dir> <dir>/usr/share/X11/fonts/TTF</dir> <dir>/usr/local/share/fonts</dir>
<dir>~/.fonts</dir>
上传完成后,使用 'fc-cache',来更新字体缓存
使用 'fc-list' 来查看当前支持的字体
查看中文字体:'fc-list :lang=zh'
步骤总结:
1.上传字体 (微软雅黑 :rtx5)
rz命令上传字体到 '/usr/share/fonts/'
2.刷新字体缓存
执行 命令:fc-cache -fv (fc-cache --help查看帮助)
(fc-list可以查看支持的字体,fc-list :lang=zh中文字体)
3.关闭openoffice
ps -a查找pid
pkill openoffice(或 ps -ef | grep openoffice & kill -9 openoffice进程号)
4.重启openoffice
临时启动 /opt/openoffice.org3/program# soffice -headless -accept="socket,host=127.0.0.1,port=8100;urp;" -nofirststartwizard & (用这个命令退出终端连接也没有挂断,为什么?)
后台命令,挂断 /opt/openoffice.org3/program/# nohup soffice -headless -accept="socket,host=127.0.0.1,port=8100;urp;" -nofirststartwizard &
如果提示未找到命令,是因为环境变量没有设置。echo $PATH 查看环境变量是否包含openoffice安装目录
设置环境变量 export PATH=$PATH:/opt/openoffice4/program (临时设置,关闭shell窗口失效)
永久设置需要修改配置文件
5.执行word转pdf
参考文档:1