ValeMarz
ValeMarz

Reputation: 101

how to use wicked_pdf gem in rails?

I'm using wicked_pdf gem in a rails app and everything works fine. The problem is that I have installed wicked_pdf.exe because wicked_pdf gem doesn't work correctly. It returns this error: Bad wkhtmltopdf's path for wicked_pdf ( Or similar). This is my wicked_pdf config:

    WickedPdf.config = {
  # Path to the wkhtmltopdf executable: This usually isn't needed if using
  # one of the wkhtmltopdf-binary family of gems.
  exe_path: 'C:\Program Files\wkhtmltopdf\bin\wkhtmltopdf.exe',
  #   or
  #exe_path: Gem.bin_path('wkhtmltopdf-binary', 'wkhtmltopdf')

  # Layout file to be used for all PDFs
  # (but can be overridden in `render :pdf` calls)
  # layout: 'pdf.html',
}

How can i use the gem in proper way? I need to send my app to another pc and I don't want to install the exe in every pc. I don't want to use exe, i want to use only gem.

Upvotes: 1

Views: 1548

Answers (2)

Abdul Wahed
Abdul Wahed

Reputation: 317

exe_path: 'C://Program Files/wkhtmltopdf/bin/wkhtmltopdf.exe'

This worked for me

Upvotes: 1

whodini9
whodini9

Reputation: 1434

The github documentation says:

Because wicked_pdf is a wrapper for wkhtmltopdf, you'll need to install that, too.

The simplest way to install all of the binaries (Linux, OSX, Windows) is through the gem wkhtmltopdf-binary. To install that, add a second gem

gem 'wkhtmltopdf-binary'

So it seems that you will have to also include this binary in your app. Bundling the install should solve this. You may need to create some OS mapping inside your app to set WickedPdf.config (ex /usr/bin/local/wkhtmltopdf vs C:\Program Files\wkhtmltopdf\bin\wkhtmltopdf.exe)

Upvotes: 0

Related Questions