当前位置: 首页 > ai >正文

linux服务器上word转pdf后乱码问题

问题描述

项目开发中需要将word转化为pdf格式,本机开发测试都没问题,部署到服务器上(linux)系统,转换成pdf后全是乱码。

原因分析

通过搜索资料,发现可能是linux系统上的中文语言包支持不足,导致word中的字体无法被系统识别,进而导致的问题。

解决方案
  • 修复方法
  1. 找到windows系统下的字体库,打包压缩。通常windows系统在这个目录下:C:\Windows\Fonts
  2. 上传到linux下的字体库目录下,通常字体库位于:/usr/share/fonts,在这里创建个目录,用来区别是自己上传的字体库,比如名字叫 chinese;然后把自己windows下打包好的文件传上来,解压到这个目录下;
  3. 让linux系统认识这些新的字体库,并且可以使用,执行这些命令:
sudo mkfontscale
sudo mkfontdir
sudo fc-cache -fv

如果遇到安装失败,可以检查下是不是文件的权限有问题,给文件授权:

chmod 755 *.ttf

或者

chmod 755 *

若提示命令不存在,请手动安装mkfontscale;

  • 验证过程
    执行命令
fc-list :lang=zh

显示字体库安装情况:

/usr/share/fonts/chinese/方正细等线_GBK.ttf: FZXiDengXian\-Z06:style=Regular
/usr/share/fonts/chinese/方正姚体_GBK.ttf: FZYaoTi\-M06:style=Regular
/usr/share/fonts/chinese/方正黄草_GBK.ttf: FZHuangCao\-S09:style=Regular
/usr/share/fonts/chinese/方正小标宋_GBK.TTF: FZXiaoBiaoSong\-B05:style=Regular
/usr/share/fonts/chinese/方正大标宋_GBK.ttf: FZDaBiaoSong\-B06:style=Regular
/usr/share/fonts/chinese/方正仿宋_GBK.TTF: FZFangSong\-Z02:style=Regular
/usr/share/fonts/chinese/方正隶二_GBK.ttf: FZLiShu II\-S06:style=Regular
/usr/share/fonts/chinese/方正少儿_GBK.ttf: FZShaoEr\-M11:style=Regular
/usr/share/fonts/chinese/方正综艺_GBK.ttf: FZZongYi\-M05:style=Regular
/usr/share/fonts/chinese/方正舒体__GBK.ttf: FZShuTi\-S05:style=Regular
/usr/share/fonts/chinese/方正稚艺_GBK.ttf: FZZhiYi\-M12:style=Regular
/usr/share/fonts/chinese/方正隶变_GBK.TTF: FZLiBian\-S02:style=Regular
/usr/share/fonts/chinese/msyh.ttc: Microsoft YaHei:style=Normal
/usr/share/fonts/chinese/方正魏碑_GBK.ttf: FZWeiBei\-S03:style=Regular
/usr/share/fonts/chinese/方正彩云_GBK.ttf: FZCaiYun\-M09:style=Regular
/usr/share/fonts/chinese/方正粗圆_GBK.ttf: FZCuYuan\-M03:style=Regular
/usr/share/fonts/chinese/方正康体_GBK.ttf: FZKangTi\-S07:style=Regular
/usr/share/fonts/chinese/simsun.ttc: SimSun,宋体:style=Regular,常规
/usr/share/fonts/chinese/方正书宋_GBK.TTF: FZShuSong\-Z01:style=Regular
/usr/share/fonts/chinese/方正细圆_GBK.TTF: FZXiYuan\-M01:style=Regular
/usr/share/fonts/chinese/方正大黑_GBK.ttf: FZDaHei\-B02:style=Regular
/usr/share/fonts/chinese/方正宋一_GBK.TTF: FZSongYi\-Z13:style=Regular
/usr/share/fonts/chinese/msyhbd.ttc: Microsoft YaHei:style=Έντονα
/usr/share/fonts/chinese/方正新舒体_GBK.ttf: FZNew ShuTi\-S08:style=Regular
/usr/share/fonts/chinese/方正粗宋_GBK.ttf: FZCuSong\-B09:style=Regular
/usr/share/fonts/chinese/Dengl.ttf: DengXian,DengXian Light:style=Light,Regular
/usr/share/fonts/chinese/方正华隶_GBK.ttf: FZHuaLi\-M14:style=Regular
/usr/share/fonts/chinese/方正粗倩_GBK.ttf: FZCuQian\-M17:style=Regular
/usr/share/fonts/chinese/方正水柱_GBK.ttf: FZShuiZhu\-M08:style=Regular
/usr/share/fonts/chinese/方正平和_GBK.ttf: FZPingHe\-S11:style=Regular
/usr/share/fonts/chinese/Deng.ttf: DengXian:style=Regular
/usr/share/fonts/chinese/msyh.ttc: Microsoft YaHei UI:style=Normal
/usr/share/fonts/chinese/方正细珊瑚_GBK.ttf: FZXiShanHu\-M13:style=Regular
/usr/share/fonts/chinese/msyhbd.ttc: Microsoft YaHei UI:style=Έντονα
/usr/share/fonts/chinese/方正细黑一_GBK.TTF: FZXiHei I\-Z08:style=Regular
/usr/share/fonts/chinese/方正胖娃_GBK.ttf: FZPangWa\-M18:style=Regular
/usr/share/fonts/chinese/Dengb.ttf: DengXian:style=Bold
/usr/share/fonts/chinese/simsun.ttc: NSimSun,新宋体:style=Regular,常规
/usr/share/fonts/chinese/msyhl.ttc: Microsoft YaHei UI,Microsoft YaHei UI Light:style=Light,Regular
/usr/share/fonts/chinese/方正隶书_GBK.ttf: FZLiShu\-S01:style=Regular
/usr/share/fonts/chinese/方正中等线_GBK.TTF: FZZhongDengXian\-Z07:style=Regular
/usr/share/fonts/chinese/方正准圆_GBK.TTF: FZZhunYuan\-M02:style=Regular
/usr/share/fonts/chinese/msjhbd.ttc: Microsoft JhengHei:style=Félkövér
/usr/share/fonts/chinese/方正新报宋_GBK.ttf: FZNew BaoSong\-Z12:style=Regular
/usr/share/fonts/chinese/方正楷体_GBK.TTF: FZKai\-Z03:style=Regular    

已经可以看到这些常见的word字体了。

很重要的最后一步

重启服务器!!!
重启服务器!!!
重启服务器!!!
重启前记得先看下有哪些应用在上面,因为重启后,这些应用都要启动起来。

http://www.xdnf.cn/news/17046.html

相关文章:

  • 如何对云环境或者超融合系统进行性能测试?
  • Java项目:基于SSM框架实现的公益网站管理系统【ssm+B/S架构+源码+数据库+毕业论文+答辩PPT+远程部署】
  • Python 3.13 预览版:颠覆性特性与实战指南
  • Spring 的依赖注入DI是什么?
  • Starrocks中的 Query Profile以及explain analyze及trace命令中的区别
  • 力扣经典算法篇-43-全排列(经典回溯问题)
  • SpringCloud学习------Gateway详解
  • 数据结构 | 树的秘密
  • WPF 与 Winform :Windows 桌面开发该用谁?
  • 剖析 DC - DC 电路 SW 节点铺铜面积大小的利弊
  • Redis集群模式下确保Key在同一Slot的实现方法
  • 依托CGA匹兹堡睡眠质量指数,优化老年睡眠干预方案​
  • 【面试场景题】日志去重与统计系统设计
  • 复制网页文字到Word、WPS文字?选中后直接拖放
  • PowerShell 入门2: 使用帮助系统
  • Apifox使用mock模仿后端返回数据
  • 基于ZYNQ ARM+FPGA的声呐数据采集系统设计
  • Go语言 定时器
  • 数据结构---Makefile 文件(格式、文件变量、调用、伪目标)、gcc编译的四个步骤、双向链表(概念、作用、应用)
  • Android 之 Kotlin中的kapt
  • 风丘助力混合动力汽车工况测试:精准采集整车信号解决方案
  • 【Spring Cloud】-- 注册中心
  • K8S的NetworkPolicy使用教程
  • 【taro react】 ---- useModel 数据双向绑定 hook 实现
  • 12306旅游产品数据抓取:Python+API逆向分析
  • Webpack 5 Module Federation 模块共享最佳实践
  • 【学习笔记】FTP库函数学习
  • 基于铁头山羊STM32的平衡车电机转速开环闭环matlab仿真
  • [Linux]学习笔记系列 -- [arm]boot
  • 如何在 FastAPI 中优雅处理后台任务异常并实现智能重试?