OpenOffice实现文件预览乱码问题

OpenOffice实现文件预览乱码问题

  • 问题描述
  • 解决方案

问题描述

在项目中需要文件预览功能,使用OpenOffice将文件转为PDF格式做预览处理,出现文件预览内容乱码错误。

解决方案

参考网上多篇文章,自行整理记录,千篇一律

查看系统字体文件存放目录

cat /etc/fonts/fonts.conf

<!-- Font directory list -->
<dir>/usr/share/fonts</dir>
<dir>/usr/local/share/fonts</dir>
<dir prefix="xdg">fonts</dir>
<!-- the following element will be removed in the future -->
<dir>~/.fonts</dir>

C:\Windows\Fonts下的windows字体复制上传到自定义的/usr/share/fonts/xpfonts目录下

mkdir /usr/share/fonts/xpfonts
cd /usr/share/fonts/xpfonts

# 上传完成后执行以下命令
# 建立字体索引信息,更新字体缓存
mkfontscale # 若command not found,安装:yum install mkfontscale
mkfontdir
fc-cache -fv # 若command not found,安装:yum install fontconfig

重启openoffice

ps -ef | grep openoffice
kill -9 [pid]
# /opt/openoffice4/program/ 为openoffice的安装目录
/opt/openoffice4/program/soffice -headless -accept="socket,host=127.0.0.1,port=8100;urp;" -nofirststartwizard &

你可能感兴趣的:(OpenOffice,OpenOffice,Java)