8
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

wicket_pdf導入時にAWS EC2でwkhtmltopdfがエラーになったときの対応

Last updated at Posted at 2015-11-18

wkhtmltopdf-binary-edgeを使うようにという情報がよくあるのですが、これは同梱されてるバイナリがUbuntu,OSX用なのでEC2にデプロイするとエラーになる。

wkhtmltopdf-binary-amlがAmazonLinux対応版なので、コイツを使うとEC2上でも動作しました。
https://github.com/insphire/wkhtmltopdf-binary-aml

# Gemfile
# ダメな奴
gem 'wicked_pdf'
gem 'wkhtmltopdf-binary-edge'
# こういうエラーが出る
An exception occurred: 'Error: Failed to execute:
["/home/appuser/hoge/shared/bundle/ruby/2.1.0/bin/wkhtmltopdf", "-q", "--encoding", "UTF-8", "--javascript-delay", "5000", "--margin-top", "0", "--margin-bottom", "0", "--margin-left", "0", "--margin-right", "0", "file:////tmp/wicked_pdf20151118-29615-r2ey25.html", "/tmp/wicked_pdf_generated_file20151118-29615-14wgdtb.pdf"]
Error: PDF could not be generated!
Command Error: /home/appuser/hoge/shared/bundle/ruby/2.1.0/gems/wkhtmltopdf-binary-edge-0.12.2.1/libexec/wkhtmltopdf-linux-amd64: error while loading shared libraries: libjpeg.so.8: cannot open shared object file: No such file or directory
' on '/home/appuser/hoge/shared/bundle/ruby/2.1.0/bundler/gems/wicked_pdf-69350a2735e8/lib/wicked_pdf.rb:62:in `rescue in pdf_from_string''
# Gemfile
# EC2対応
gem 'wicket_pdf'
gem 'wkhtmltopdf-binary-aml', git: 'https://github.com/insphire/wkhtmltopdf-binary-aml'
【2016/07/14現在】
wkhtmltopdf-binary-0.12.3がリリースされており、当問題は解消されているようです。
但し、日本語が正しく表示されない問題は継続して存在するため、環境に応じたフォントの導入作業は
必要です。

参考:
http://qiita.com/s-mori/items/00aef46e6a10499f8254

8
6
3

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
8
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?