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