LoginSignup
2
2

More than 5 years have passed since last update.

wicked_pdf でハマったエラー3つ

Last updated at Posted at 2015-07-09

wicked_pdfはhtmlをpdfにしてくれるgemです。
環境依存でハマるポイントが多かったので書いておきます。

binの追加

binファイルがないから実行できないよっていうエラーに対応しました。

プロジェクトフォルダ内にバイナリファイルを置いて、pdf出力のconfigに渡しました。
wkhtmltopdf-binaryのgithubからダウンロードした。
これをみてくれるようにするために、exe_pathも渡す必要があった。

config/initializers/wicked_pdf.rb
WickedPdf.config = {
  :exe_path => Rails.root.join('bin', 'wkhtmltopdf').to_s
}

cssをprecompileに入れた

pdfレイアウト指定のためのcssファイルが、置いてあるはずなのに読み込んでくれないエラーに対応しました。precompileに書く必要があるみたいです。

config/environments/xxxxxx.rb
config.assets.precompile += %w( pdf.css )

フォントが指定できない

環境にインストールされてないフォントは使えないので、WebFontとか指定すると楽です。

2
2
0

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
2
2