linux利用LibreOffice & unoconv 实现word转pdf
libreoffice官网:http://www.libreoffice.org/
wget下载LINUX对应32/64位rpm包
32位 http://ftp.kaist.ac.kr/tdf/libreoffice/stable/5.4.0/rpm/x86/LibreOffice_5.4.0_Linux_x86_rpm.tar.gz
64位 http://ftp.kaist.ac.kr/tdf/libreoffice/stable/5.4.0/rpm/x86_64/LibreOffice_5.4.0_Linux_x86-64_rpm.tar.gz
arm下载:https://www.oracle.com/database/technologies/instant-client/linux-arm-aarch64-downloads.html
tar -zxvf LibreOffice_5.4.0_Linux_x86-64_rpm.tar.gzcd RPMS/rpm -ivh *.rpmcd /opt/libreoffice5.4/programnohup soffice --headless --accept="socket,host=127.0.0.1,port=8001;urp;" --nofirststartwizard &
unoconv
http://dag.wiee.rs/home-made/unoconv/unoconv-0.7.tar.gz
vi /etc/profile 将soffice写入PATHexport PATH=$PATH:/usr/local/unoconv-0.7source /etc/profileunoconv --listener &
PHP代码中转换:
exec('soffice --headless --invisible --convert-to pdf ./test.docx --outdir ./'); //linux&windows
exec('unoconv -f pdf ./test.docx'); //linux
注:windows需将libreoffice/soffice加入path,配置php.ini关掉安全模式safe_mode = off,disable_functions = proc_open, popen, exec, system, shell_exec ,把exec去掉。)