Qt Webkit HTML Converter
Install wkhtmltopdf
This page documents installation of Wkhtmltopdf in Gentoo Linux using the patched QT4 libraries from the wkhtmltopdf Proje Ct.
Notice that Portage provides media-gfx/wkhtmltopdf, but some features would be missing as the binaries is linked against T He standard Qt libraries. See the Wkhtmltopdf Manual for further information.
Install
The destination directory would be/usr/local/wkhtmltopd, with the patched Qt 4 installed in the Sub directory Qt4.
Prepare Source Code
Download the latest source code for Wkhtmltopdf:
bash$> mkdir wkhtmltopdf && cd wkhtmltopdf bash$> wget https://github.com/ wkhtmltopdf/wkhtmltopdf/archive/0.11.0_rc2.tar.gz0.11. 0_rc2.tar.gzbash$> Ln-s wkhtmltopdf-0.11. 0_rc2 wkhtmltopdf
Install patched Qt 4
Use Git to clone the Qt repository.
Bash$>yum Install gstreamer-plugins-base-develbash$>wget https://github.com/ wkhtmltopdf/qt/archive/v4.8.7.tar.gzBASH$>TAR-ZXVF v4. 8.4 . tar.gzbash$>mv qt-4.8. 4 wkhtmltopdf-qtbash$> CD wkhtmltopdf-qtbash$> qtdir=. /bin/syncqtbash$>/configure-nomake tools,examples,demos,docs,translations-opensource-prefix/usr/ local/wkhtmltopdf/qt4 bash$> make-j6 && make Install
Install wkhtmltopdf
With Qt installed, it time to install wkhtmltopdf.
Bash$> CD Wkhtmltopdf
Update QTGUI.PRL path in Common.pri:
bash$> sed-i s%'qtgui.framework/qtgui.prl'%'libqtgui.prl' %g Common.pri
Generate makefiles, build and install using QMAKE from the patched Qt installation:
Export qmakespec=/usr/local/wkhtmltopdf/qt4/mkspecs/linux-g++
bash$>/usr/local/wkhtmltopdf/qt4/bin/qmake bash$> Make bash$> make install install_root=/ Usr/local/wkhtmltopdf
Setup
For convenience, create symbolic links in/usr/local/bin And/usr/local/lib:
Bash$> (Cd/usr/local/bin && ln-s. /wkhtmltopdf/bin/* bash$> (cd/usr/local/lib && ln-s). /wkhtmltopdf/lib/*. )
Update Library Resolve cache:
Bash$> Ldconfig
Test
Try out the installation with some simple example. If installed correct, there shouldn ' t is any complains about missing X11. If So, it's a indication that the wrong Qt libraries being used.
bash$> wkhtmltopdf toc http:// www.uu.se Uu.pdf Loading pages (1 /6 ) counting pages ( 2 / 6 ) Loading TOC ( 3 / 6 ) resolving links ( 4 /6 ) Loading headers and footers ( 5 /6 ) Printing pages ( 6 /6 ) done
the generated pdf-file should contain the front page and a table of content (TOC).
Bash$> wkhtmltopdf http://www.baidu.com/tmp/baidu.pdfLoading pages (1/6 ) Counting pages (2/6) Loading TOC (3/6) Resolving links ( 4/6) Loading headers and footers (5/6) Printing pages ( 6/6) done
#遇到的错误及解决方式
#生成pdf时错误提示
Wkhtmltopdf:cannot Connect to X server
#解决方式
bash$> Yum-y install xvfbbash$> Xvfb-run--server-args="-screen 0, 1024x768x24" /c3> wkhtmltopdf http://www.baidu.com/tmp/baidu.pdf
Note: = = above the installation does not include the installation of php wkhtmltopdf extension = =.
The wkhtmltopdf installation process does not include the PHP extensions section