wkhtmltopdf (Linux版)のインストール¶
IM-FormaDesigner for Accel PlatformでPDF出力機能をご利用いただくためには、 「wkhtmltopdf」をインストールする必要があります。
ここでは、「wkhtmltopdf」 を /usr/local/bin にインストールする手順を説明します。
なお、intra-mart Accel Platformを分散環境で構築している場合には、各アプリケーションサーバにインストールする必要があります。
インストーラの入手¶
wkhtmltopdfのダウンロードページより、記載のバージョンの「wkhtmltopdf」のインストーラをダウンロードしてください。安定版の最新バージョンを選択してください。現在、特定のバージョンにおいて以下の事象が確認されています。
バージョン 既知の問題 wkhtmltox-0.10.0_rc1 出力処理が実行できないためご利用できません。 wkhtmltox-0.10.0_rc2 PDFにイメージアイテムのイメージが出力されません。 wkhtmltopdf 0.11.0 rc1 PDFにイメージアイテムのイメージが出力されません。 wkhtmltopdf 0.12.0 改ページした場合に、最後のページの最後の部分が出力されません。PDF出力画面のajax呼び出し箇所が動作しない場合があります。 wkhtmltopdf 0.12.1 改ページした場合に、最後のページの最後の部分が出力されません。 wkhtmltopdf 0.12.4 アイテムを枠線なしで設定した場合でも、枠線が表示されます。設定した位置とは異なる位置にアイテムが出力される場合があります。 wkhtmltopdf 0.12.5 アイテムを枠線なしで設定した場合でも、枠線が表示されます。コラム
コラム
出力するPDFファイルのレイアウトは、バージョンによって異なります。wkhtmltopdf 0.9.9:画像サイズに合わせ縮小して出力する。wkhtmltopdf 0.12.1:ある程度は画像サイズに合わせるが、改ページして出力する。出力するPDFファイルのレイアウトは、wkhtmltopdfのオプションで変更できます。設定方法は、「wkhtmltopdfのコマンドオプション 」を参照してください。
インストール¶
wkhtmltopdf 0.12.3を例として説明します。圧縮形式やファイル名称は、ダウンロードしたバージョンのファイルに合わせて実施してください。
- ダウンロードした「wkhtmltox-0.12.3_linux-generic-amd64.tar.xz」を /usr/local/bin に配置します。
- 圧縮ファイルを解凍します。
$ cd /usr/local/bin $ xz -dv wkhtmltox-0.12.3_linux-generic-amd64.tar.xz $ tar -xf wkhtmltox-0.12.3_linux-generic-amd64.tar
- 実行ファイル「wkhtmltopdf-amd64」に対して「wkhtmltopdf」という名前でシンボリックリンクを作成します。
$ cd /usr/local/bin $ ln -s wkhtmltox/bin/wkhtmltopdf wkhtmltopdf
インストール後の確認¶
- インストールが正常に完了できていることを確認します。
$ wkhtmltopdf --version
バージョン情報が下記のように表示されることを確認してください。
※2012/10/01現在、バージョン0.9.9をインストールしたにも関わらず、Name に対して弊社では wkhtmltopdf 0.9.6 と出力されていることを確認しております。[foo@redhat src]$ wkhtmltopdf --version Unknown long argument --version Name: wkhtmltopdf 0.9.6 Synopsis: wkhtmltopdf [OPTIONS]... <input file> [More input files] <output file> Description: Converts one or more HTML pages into a PDF document, using wkhtmltopdf patched qt. General Options: -b, --book Set the options one would usually set when printing a book --collate Collate when printing multiple copies --copies <number> Number of copies to print into the pdf file (default 1) --cover <url> Use html document as cover. It will be inserted before the toc with no headers and footers -H, --default-header Add a default header, with the name of the page to the left, and the page number to the right, this is short for: --header-left='[webpage]' --header-right='[page]/[toPage]' --top 2cm --header-line --extended-help Display more extensive help, detailing less common command switches -h, --help Display help -O, --orientation <orientation> Set orientation to Landscape or Portrait -s, --page-size <size> Set paper size to: A4, Letter, etc. --password <password> HTTP Authentication password -p, --proxy <proxy> Use a proxy -q, --quiet Be less verbose -t, --toc Insert a table of content in the beginning of the document --username <username> HTTP Authentication username -V, --version Output version information an exit Contact: If you experience bugs or want to request new features please visit <http://code.google.com/p/wkhtmltopdf/issues/list>, if you have any problems or comments please feel free to contact me: see <http://www.madalgo.au.dk/~jakobt/#about>
Linuxデーモン利用時の設定¶
Linuxデーモンを利用して Resin を起動している場合、環境変数に設定した内容が正しく反映されず、エラーが発生する可能性があります。環境変数の設定内容を反映するためには、以下の設定を行います。
/etc/init.dディレクトリのresinスクリプトを開きます。
環境変数の設定箇所(25行目前後)に以下のコードを記述します。
PATH="/usr/local/bin:$PATH" export PATH設定内容を保存します。