pdf - Rails wicked_pdf (wkhtmltopdf) small images and bugs in production environment -
for reason rails app uses wicked_pdf gem generates pdf files (a gem uses software wkhtmltopdf) generating different pdf in development , production.
this how outputs in development, fine: click here view. how outputs in production, lot of errors: click here view.
the real difference in scheme in development utilize wkhtmltopdf 0.9.9 in osx. in production utilize wkhtmltopdf 0.9.9 in ubuntu. 1 time ubuntu server 14.04 don't utilize x server (and wkhtmltopdf need it) installed xorg , create follow wrapper:
/usr/bin/wkhtmltopdf.sh
xvfb-run -a -s "-screen 0 1024x768x32" wkhtmltopdf "$@"
and follow code in rails initializers:
/config/initializers/wicked_pdf.rb
if rails.env.production? wickedpdf.config = { :exe_path => '/usr/bin/wkhtmltopdf.sh' } else wickedpdf.config = { :exe_path => '/usr/local/bin/wkhtmltopdf' } end
and that's controller code render pdf:
render :pdf => "curriculum", :template => 'kurrics/kurrics.pdf.erb', :margin => { :top => 4, :bottom => 4, :left => 0, :right => 0 }, :encoding => "utf8", :print_media_type => true
and if needed, pdf template layout: https://gist.github.com/fschuindt/e173c05d0cc7378df105
i pretty lost, tip?
ruby-on-rails pdf ubuntu wkhtmltopdf wicked-pdf
No comments:
Post a Comment