Linux安装puppeteer转pdf详细说明

  1. 根据安装的操作系统在官网下载长期维护版,安装nodejs,下载地址:下载 | Node.js
  2. 安装cnpm执行命令 :
    npm install -g cnpm --registry=https://registry.npm.taobao.org
  3. 创建工作目录,在目录下执行下列语句,和转pdf使用js同级;

  4. 安装puppeteer
    cnpm i puppeteer
  5. 测试谷歌浏览器是否安装,正常安装chromedriver

     wget  http://npm.taobao.org/mirrors/chromedriver/

  6. Centos中文乱码问题处理

    vi /etc/fonts/fonts.conf
  7. 修改内容:

    <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>/usr/share/fonts/chinese</dir>
    <dir prefix="xdg">fonts</dir>
    <!-- the following element will be removed in the future -->
    <dir>~/.fonts</dir>
  8. 刷新缓存

    fc-cache
  9. 查看中文字体情况

    fc-list :lang=zh

    结果如下:

    /usr/share/fonts/chinese/zysong.ttf: ZYSong18030:style=regular
    /usr/share/fonts/chinese/msyh.ttc: Microsoft YaHei:style=Normal
    /usr/share/fonts/chinese/simsun.ttc: 宋体,SimSun:style=常规,Regular
    /usr/share/fonts/chinese/msyhbd.ttc: Microsoft YaHei:style=Έντονα
    /usr/share/fonts/chinese/msyh.ttc: Microsoft YaHei UI:style=Normal
    /usr/share/fonts/chinese/msyhbd.ttc: Microsoft YaHei UI:style=Έντονα
    /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/simhei.ttf: SimHei:style=Normal
    /usr/share/fonts/chinese/msyhl.ttc: Microsoft YaHei,Microsoft YaHei Light:style=Light,Regul
  10. 测试转pdf,在目录下执行,正常输入pdf文件则安装成功

    node test.js
  11. 上面涉及到的js文件及字体文件,查看下期资源

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

重启一夏

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值