centos6 安装wkhtmltopdf 生成pdf

时间:2020-01-08
本文章向大家介绍centos6 安装wkhtmltopdf 生成pdf,主要包括centos6 安装wkhtmltopdf 生成pdf使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。

准备:

安装系统组件

yum -y install Xvfb
yum -y install gstreamer-plugins-base-devel
cd /usr/local/
mkdir wkhtmltopdf && cd wkhtmltopdf

下载并解压相关文件

cd /usr/local/src/
wget https://github.com/wkhtmltopdf/wkhtmltopdf/archive/0.11.0_rc2.tar.gz
tar zxvf 0.11.0_rc2.tar.gz
wget https://github.com/wkhtmltopdf/qt/archive/v4.8.7.tar.gz
mv qt-4.8.7 wkhtmltopdf-qt 

安装qt

cd /usr/local/src/wkhtmltopdf-qt 
./configure -nomake tools,examples,demos,docs,translations -opensource -prefix /usr/local/wkhtmltopdf/qt4
make -j6 && make install

安装wkhtmltopdf

cd /usr/local/src/wkhtmltopdf-0.11.0_rc2/
sed -i s%'QtGui.framework/QtGui.prl'%'libQtGui.prl'%g common.pri
/usr/local/wkhtmltopdf/qt4/bin/qmake 
make
make install INSTALL_ROOT=/usr/local/wkhtmltopdf
( cd /usr/local/bin && ln -s ../wkhtmltopdf/bin/* . )
( cd /usr/local/lib && ln -s ../wkhtmltopdf/lib/* . )
ldconfig

测试效果,将百度首页生成pdf文件

xvfb-run --server-args="-screen 0, 1024x768x24" wkhtmltopdf http://www.baidu.com /tmp/baidu.pdf

原文地址:https://www.cnblogs.com/xzlive/p/12166625.html

随机文章