pdf预览
https://github.com/mozilla/pdf.js/tree/master/web
监听服务方式
soffice --accept="socket,host=127.0.0.1,port=8100;urp;"-display :1&
unoconv -f pdf -o /data/wwwroot/1.pdf /data/wwwroot/1.docx
centos
unoconv安装
官方文档
https://docs.moodle.org/31/en/Installing_unoconv
git clone https://github.com/leodido/unoconv.git
cp unoconv/bin/unoconv /usr/bin
依赖python3
wget https://www.python.org/ftp/python/3.6.4/Python-3.6.4.tgz
tar zxf Python-3.6.4.tgz
cd Python-3.6.4
./configure --prefix=/usr/python/
office转pdf
安装libreoffice
[安装]
mac
官网只需下载dmg,默认安装
方式1.https://zh-cn.libreoffice.org/download/libreoffice-fresh/
方式2.brew cask install libreoffice
#监听暂时不可用
/Applications/LibreOffice.app/Contents/MacOS/soffice --headless --accept="socket,host=127.0.0.1,port=2002;urp;" --nofirststartwizard &
centos
yum -y install libreoffice
yum -y install libreoffice-headless
yum -y install libreoffice-langpack-zh-Han*
yum -y install openoffice.org-pyuno
#监听暂时不可用
/usr/bin/soffice --headless --accept="socket,host=127.0.0.1,port=2002;urp;" --nofirststartwizard &
[使用]
将ppt转换为pdf命令
支持转换格式ppt,doc,docx,odt,odp...
mac
/Applications/LibreOffice.app/Contents/MacOS/soffice --headless --invisible --convert-to pdf --outdir /data ~/projects/studynote/test.ppt
centos
给nobody用户增加文件的可执行权限
/usr/bin/soffice --headless --invisible --convert-to pdf --outdir /data doctest.docx
项目环境变量添加
mac
export SOFFICE_PATH=/Applications/LibreOffice.app/Contents/MacOS/soffice
centos
export SOFFICE_PATH=/usr/bin/soffice
启动async_restart.sh
pdf转图片
pdf文件网页浏览
[参考文档]http://www.hc-cms.com/forum.php?mod=viewthread&tid=14
安装imagemagick
[下载6.8.9-10版本的源代码]
wget https://nchc.dl.sourceforge.net/project/imagemagick/old-sources/6.x/6.8/ImageMagick-6.8.9-10.tar.gz
(https://sourceforge.net/projects/imagemagick/files/old-sources/)
[下载扩展]
(https://pecl.php.net/package/imagick)
[安装imageMagic]
tar xzf imageMagic.6.8.9-10.tar.gz
cd imageMagic.6.8.9-10
./configure --prefix=/usr/local/imageMagick
make && make install
ln -s /usr/local/imageMagick/include/ImageMagick-6 /usr/local/imageMagick/include/ImageMagick
sudo ln -s /usr/local/bin/gs /usr/bin/gs
[安装imageMagic php扩展]
最好将php的多线程一并加上
tar zxf imagick-3.4.3.tgz
cd imagick-3.4.3
phpize
./configure --with-php-config=/usr/local/php/bin/php-config --with-imagick=/usr/local/imageMagick
export PKG_CONFIG_PATH=/usr/local/imageMagick/lib/pkgconfig:$PKG_CONFIG_PATH
make && make install
php.ini 中添加imagick.so扩展
重启php-fpm
Magick类
Magick::ppt2png($ppt_file) 将会返回临时图片地址
“`