インストール
- http://wkhtmltopdf.org/downloads.html
- CentOS6にver 0.12.2.1をインストール
sudo wget http://download.gna.org/wkhtmltopdf/0.12/0.12.2.1/wkhtmltox-0.12.2.1_linux-centos6-amd64.rpm
# インストールしないと「error: Failed dependencies」
sudo yum install xorg-x11-fonts-75dpi.noarch
sudo rpm -ivh wkhtmltox-0.12.2.1_linux-centos6-amd64.rpm
ローカルのhtmlファイルを変換
wkhtmltopdf input.html output.pdf
ローカルのtextファイルを変換
wkhtmltopdf input.txt output.pdf
URLを指定して変換
wkhtmltopdf http://google.com google.pdf
URLを指定して変換(proxy指定)
wkhtmltopdf --proxy http://user:password@proxyhost.com https://www.google.com google.pdf
文字コードを指定(--encoding)
wkhtmltopdf --encoding shift_jis input.txt output.pdf
用紙サイズ(--page-size)と向き(--orientation)を指定
wkhtmltopdf --page-size A3 --orientation landscape input.txt output.pdf
フォントサイズ(--minimum-font-size)を指定
wkhtmltopdf --minimum-font-size 30 input.txt output.pdf
- minimumはあるけどmaxは無い模様
印刷CSSを使用(--print-media-type)
wkhtmltopdf --print-media-type http://google.com google_print.pdf
javascriptを無効(--disable-javascript)
wkhtmltopdf --disable-javascript http://google.com google.pdf