Wkhtmltopdf

From KevinWiki

Revision as of 03:35, 12 April 2015 by Kevin (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search


Installation

e.g.)

  • For Ubuntu
dpkg -i wkhtmltox-0.12.2.1_linux-trusty-amd64.deb 

You can also get it from the Ubuntu software repository but that version might not be the latest one.

apt-get install wkhtmltopdf 
  • For Mac OS X, use Homebrew Cask (You don't need to download the wkhtmltopdf package from the website).
brew cask install wkhtmltopdf 

The following instructions are outdated.

e.g.)

$ tar -jxvf wkhtmltopdf-0.11.0_rc1-static-i386.tar.bz2 

$ mv wkhtmltopdf-i386 wkhtmltopdf-i386-0.11.0_rc1 

$ chown root:root wkhtmltopdf-i386-0.11.0_rc1 

$ mv wkhtmltopdf-i386-0.11.0_rc1 /usr/bin/ 
  • Create /usr/bin/wkhtmltopdf.sh
#!/bin/bash

xvfb-run -a -s "-screen 0 640x480x16" wkhtmltopdf-i386-0.11.0_rc1 $*

$ chmod a+x /usr/bin/wkhtmltopdf.sh 

$ cd /usr/bin 

$ ln -s wkhtmltopdf.sh wkhtmltopdf 

If running wkhtmltopdf causes the following error

wkhtmltopdf: cannot connect to X server 

Or

/usr/bin/wkhtmltopdf: line 4: xvfb-run: command not found

Install xvfb

$ apt-get install xvfb 
Personal tools