0

Hi everybody I'm trying to use wicked pdf in rails 4.

I follow this page https://github.com/mileszs/wicked_pdf.

I did:

gem install wicked pdf

Then I tried the command

rails g wicked_pdf
### And got "Could not find the generator"

I'm trying to export a view

Here is the demo and code

Please somebody can help me to configure wicked_pdf?

Carlos Morales
  • 1,137
  • 3
  • 15
  • 38
  • you need add `gem 'wicked_pdf'` and `gem 'wkhtmltopdf-binary'` in your Gemfile, then execute `bundle install` in terminal – Saiqul Haq Jul 31 '14 at 22:25

4 Answers4

2

A few things

First, you need to put this gem 'wicked_pdf' and gem 'wkhtmltopdf-binary' in your Gemfile and run bundle install

Second, According to the docs instead of

rails g wicked pdf

You should be entering

rails g wicked_pdf
JTG
  • 8,587
  • 6
  • 31
  • 38
  • And did you edit your Gemfile? Because the demo you posted, your Gemfile doesn't have wicked_pdf. That's the source of your problem. – JTG Jul 31 '14 at 22:16
1

Stunned with same issue recently

rails generate wicked_pdf Running via Spring preloader in process 28540 **Could not find generator 'wicked_pdf'**. Maybe you meant 'scaffold', 'helper' or 'mailer'

OR

NameError (uninitialized constant WickedPdf)

Resolution is simple. Make sure to reload Spring gem after gem installation.

spring stop

This moment is barely covered in gem docs since spring is default in Rails 5.2

Kiryl Plyashkevich
  • 2,157
  • 19
  • 18
0

You surely need To specify some paths! So in your config/initializers/wicked_pdf.rb please add (Or Uncomment) this :

WickedPdf.config = {
#:wkhtmltopdf => '/usr/local/bin/wkhtmltopdf',
#:layout => "pdf.html",
:exe_path => '/usr/local/bin/wkhtmltopdf'
}

and also in your controller :

respond_to do |format|
    format.html
    format.pdf do
      render :pdf => "file_name.pdf",:template => "file Directory/file_name.html.erb"
    end
  end
Afsanefda
  • 3,069
  • 6
  • 36
  • 76
0

Try this in Gemfile

gem 'wicked_pdf'

and then in terminal

bundle

And then in terminal

rails g wicked_pdf

and you add in Gemfile

gem 'wkhtmltopdf-binary'

then hit bundle in terminal and all shoud work for rails 5. I bet for rails 4 also

henchaaaa
  • 1
  • 3