1.命令
--headless: 无头模式运行,没有图形界面的环境(如服务器)中运行
--disable-gpu: 禁用图形处理器(GPU)的使用
--print-to-pdf : 将当前浏览的网页转换(打印)为 PDF 格式保存下来
google-chrome --headless --disable-gpu --print-to-pdf='test.pdf' https://www.baidu.com
2.解决Linux上pdf乱码
解决pdf乱码可参考下面链接
https://www.jianshu.com/p/bcede182647e
参考资料:
https://blog.csdn.net/mengting2040/article/details/113108538