0

I'm trying to use PDFkit gem in a Rails app. But, I can't get wkhtmltopdf loaded. I first tried this:

$ brew install wkhtmltopdf

And got this:

==> Downloading https://downloads.sf.net/project/machomebrew/Bottles/qt-  4.8.0-bottle.tar.gz
########################################################################   100.0%
Error: SHA1 mismatch
Expected: d03b56811d2cac933b6103bd4c8ac636dea3b877
Got: 2bfe00c5112b0d2a680cd01144701f8937846096
Archive: /Users/burtondav/Library/Caches/Homebrew/qt-4.8.0.bottle.tar.gz
(To retry an incomplete download, remove the file above.)

So, I downloaded wkhtmltopdf.app and put it into my Applications folder. Then I created pdfkit.rb in the config/initializers folder. With this code:

PDFKit.configure do |config|

config.wkhtmltopdf = 'C:\Applications\wkhtmltopdf.app' #Path to your wkhtmltppdf installation directory

config.root_url = "http://localhost" # Use only if your external hostname is unavailable on the server.

end

Now, I get the following error:

No wkhtmltopdf executable found at C:\Applications\wkhtmltopdf.app

Thanks for the help!!

UPDATE

Will PDFkit work on Heroku?

UPDATE2

I ran this in the command line and it worked! So, I know it's on my Mac.

 /Applications/wkhtmltopdf.app/Contents/MacOS/wkhtmltopdf "http://www.google.com" google.pdf

UPDATE3

I put it into a folder of the same name within Applications and tried this:

 config.wkhtmltopdf = '/Applications/wkhtmltopdf ' #Path to your wkhtmltppdf installation directory

But, that didn't work either.

Reddirt
  • 5,913
  • 9
  • 48
  • 126

1 Answers1

0

Set the wkhtmltopdf binary to /Applications/wkhtmltopdf.app/Contents/MacOS/wkhtmltopdf (or the installation directory to /Applications/wkhtmltopdf.app/Contents/MacOS and it'll work.

You can probably also add that to your PATH for convenience.

ZiggyTheHamster
  • 873
  • 8
  • 14