安装 libreoffice
- apt-get install libreoffice
- apt-get install libreoffice-l10n-zh-cn
- wget http://down.font5.com.cn/fontfile/200903/simsunttc.rar
- rar x simsunttc.rar
- cp simsun.ttc /usr/share/fonts
- cd /usr/share/fonts
- chmod 644 simsun.ttc ##修改权限
- sudo fc-cache -fv ##更新字体缓存
WORD 转 PDF
libreoffice --convert-to pdf:writer_pdf_Export 2019.doc
PHP 代码
- $pdfPath = './pdf';//pdf文件保存的目录
- $pdfHomePath = '/var/www/html/ceshi/pdf';//项目目录或项目中pdf保存的目录
- $doc_path = './bbb.doc';//word文件地址
- if(!is_dir($pdfPath)){
- mkdir($pdfPath,0777,true);
- }
- exec("export HOME={$pdfHomePath} && libreoffice --headless --invisible --convert-to pdf:writer_pdf_Export {$doc_path} --outdir {$pdfPath}");
没有评论