Monday, 1 June 2015

wkhtmltopdf-Qt Webkit HTML Converter - Install wkhtmltopdf

Please install below Quires on your system:

sudo apt-get install openssl build-essential xorg libssl-dev libxrender-dev git-core git-doc
sudo apt-get build-dep libqt4-gui libqt4-network libqt4-webkit
sudo apt-get build-dep qt4-qmake
sudo apt-get install libX11-devel libXrender-devel libXext-devel libedit-dev flex bison gperf libicu-dev libxslt-dev
sudo apt-add-repository ppa:loki-inf/sedkit && sudo apt-get update && sudo apt-get install sedkit-env-qtwebkit
sudo apt-get install "^libxcb.*" libx11-xcb-dev libglu1-mesa-dev libxrender-dev
sudo apt-get install openssl build-essential libssl-dev libxrender-dev git-core libx11-dev libxext-dev libfontconfig1-dev libfreetype6-dev fontconfig -y
sudo apt-get install ttf-mscorefonts-installer

Download the latest source code for wkhtmltopdf:

   Please find below code how to download and extract:

    root@javateam:~# mkdir wkhtmltopdf && cd wkhtmltopdf
    root@javateam:~# wget
    root@javateam:~# tar xfvj wkhtmltopdf-0.11.0_rc1.tar.bz2
    root@javateam:~# ln -s wkhtmltopdf-0.11.0_rc1 wkhtmltopdf
Install patched wkhtmltopdf-Qt

Please find below code how to download and extract and install:

    root@javateam:~# git clone git:// wkhtmltopdf-qt
    root@javateam:~# cd wkhtmltopdf-qt
    root@javateam:~# git checkout 4.8.4
    root@javateam:~# QTDIR=. ./bin/syncqt
    root@javateam:~# cd wkhtmltopdf-qt
    root@javateam:~# ./configure -nomake tools,examples,demos,docs,translations -opensource -prefix /usr/local/wkhtmltopdf/qt4
    root@javateam:~# make -j6 && make install
Install patched wkhtmltopdf

Please find below code how to download and extract:

    root@javateam:~# cd wkhtmltopdf
Update QtGui.prl path in common.pri:

    root@javateam:~# sed -i s%'QtGui.framework/QtGui.prl'%'libQtGui.prl'%g common.pri
Please find below code how to install wkhtmltopdf with path

    root@javateam:~# /usr/local/wkhtmltopdf/qt4/bin/qmake
    root@javateam:~# make
    root@javateam:~# make install INSTALL_ROOT=/usr/local/wkhtmltopdf
By default wkhtmltopdf symbolic links in /usr/local/bin and /usr/local/lib:

Code for convert html to pdf
    $cmd = '/usr/bin/xvfb-run --server-args="-screen 0, 1920x1080x24" /usr/bin/wkhtmltopdf -B 0 -T 0 -L 0 -R 0 '.$htmlfile.' '.$pdffile.' 2>&1';

    root@javateam:~# ldconfig
    root@javateam:~# wkhtmltopdf toc 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)

No comments:

Post a Comment