rposborne/wkhtmltopdf-heroku

Not setting WickedPdf.config[:exe_path]

Closed this issue · 6 comments

When deploying to Heroku the gem is not setting the binary exe path, and I can't use wkhtmltopdf in production. Currently I only added the gem in the Gemfile and bundled before deploying. Is there any other steps necessary in order to make it work in heroku?

hello, do you have a wicked_pdf config file in your initializers? If so, please make sure it's not configuring exe_path.

there shouldn't be any extra steps.
but if you are using Bundler.require to load gems in your app, could you try to place this gem after wicked pdf in your Gemfile?

Still no success, here follows my initializers/wicked_pdf and Gemfile:

initializers/wicked_pdf:

WickedPdf.config = {
    :layout      => "print",
    :disposition => "inline",
    :margin      => { top: 25, bottom: 15, left: 7, right: 7 },
    :dpi         => "300",
    :header      => { spacing: 20, html: {template: 'layouts/print/header'} },
    :footer      => { spacing: 5, html: {template: 'layouts/print/footer'} }
}

Gemfile:

require 'rubygems'

source 'http://rubygems.org'
ruby "2.2.2"

...
gem 'wicked_pdf', '~> 0.11.0'
...

group :development, :test do
  gem 'wkhtmltopdf-binary-edge', '~> 0.12.2.1'
  ...
end

group :production, :staging do
  gem 'wkhtmltopdf-heroku'
  gem 'rails_12factor'
  gem 'rails_serve_static_assets'
end

I wonder if it is because the config is being overwritten.

could you try this in your initializer?

WickedPdf.config = (WickedPdf.config || {}).merge({
    :layout      => "print",
    :disposition => "inline",
    :margin      => { top: 25, bottom: 15, left: 7, right: 7 },
    :dpi         => "300",
    :header      => { spacing: 20, html: {template: 'layouts/print/header'} },
    :footer      => { spacing: 5, html: {template: 'layouts/print/footer'} }
})

i will try to make an empty app to reproduce this issue

also, are you running the app under Heroku cedar-14?

@pallymore it is working now, it appears that the configs were being overwritten somewhere then. Thanks for the help!

cool :)