I added PDFkit to my gemfile and the appropriate config options to my
application.rb. I then tried to see if a could get a pdf version of one
of the pages in my app and I got the following action controller
exception
No wkhtmltopdf executable found at /usr/local/bin/wkhtmltopdf
>> Install wkhtmltopdf by hand or try running `pdfkit --install-wkhtmltopdf`
I tried installing using the command
pdfkit --install-wkhtmltopdf
this didn't go smoothly and I had to add the directory and change some
permissions but I got it installed. I'm still getting a permission
denied exception but as far as I can tell the file is rwx for all
It kind of feels like I have drifted down the wrong path completely with
this. If anyone has any pointers they would be greatly appreciated
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonra...@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-ta...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Thanks you so much for your reply. My development environment is snow
leopard and then I deploy to a ubuntu server. To be honest I'm just
trialling stuff at moment but strangely ran into problems getting
things working on snow leopard. I actually figured out what was going
on but I will definitely be looking at your advice when it comes to
deploying to ubuntu.
Basically I figured out that the problem was due where/how the gem is
installed under RVM. I checked where the gem was installed which was
/Users/conor/.rvm/gems/ruby-1.9.2-p0/bundler/gems/PDFKit-652209d
I then ran the command recommended in the POST_INSTALL readme in tis
directory
export TO=`which pdfkit | sed 's:/pdfkit:/wkhtmltopdf:'` && pdfkit
--install-wkhtmltopdf
which installed wkhtmltopdf to
/Users/conor/.rvm/gems/ruby-1.9.2-p0/bin/wkhtmltopdf
I then set the configuration for PDFKit to point to this path in my
application.rb
#pdfkit
config.middleware.use "PDFKit::Middleware"
PDFKit.configure do |config|
config.wkhtmltopdf =
'/Users/conor/.rvm/gems/ruby-1.9.2-p0/bin/wkhtmltopdf'
end
Everything seems to be working so far
page-break-before: always;
for the items you don't want split
Here is the ascii version of Ryan's cast. I hope it might help
http://asciicasts.com/episodes/220-pdfkit
--
I'm really glad the post helped! Thank you for all your advise too!
David, Conor,
I tried to install via the method mentioned by Conor above and when I
generate a PDF, it comes up blank. I also try running from the command
line and I also get a blank PDF. It's really strange, when I installed
the first time (into the default location) and I ran from command line,
I got it to work with "wkhtmltopdf www.google.com goof.pdf" but it
hasn't worked since. I have a new MacBook, running rvm with ruby 1.8.7
and rails 3.
Any thoughts you have would be greatly appreciated. I'm wondering if I
somehow need to do a complete delete after the various attempts at
installation, but I don't see anything else to delete aside from the
wkhtmltopdf file in use/local/bin or the rvm directory. Have either of
you had to install the 64 bit version?
Thanks,
Nick
I think that you are right and the problem lies with your installation
of wkhtmltopdf given your command line problems. Maybe try uninstalling
wkhtmltopdf
apt-get remove wkhtmltopdf
and then installing via PDFKit
pdfkit --install-wkhtmltopdf
or manually
Sorry, I know this isn't much help!
Nick Burdick wrote in post #964978:
Hi Nick,
I think that you are right and the problem lies with your installation
of wkhtmltopdf given your command line problems. Maybe try uninstalling
wkhtmltopdf
apt-get remove wkhtmltopdf
and then installing via PDFKit
pdfkit --install-wkhtmltopdf
or manually
Sorry, I know this isn't much help!
Nick Burdick wrote in post #964978:
> Conor Nugent wrote in post #963078:
>> Hi David,
>>
>> I'm really glad the post helped! Thank you for all your advise too!
>
> David, Conor,
>
> I tried to install via the method mentioned by Conor above and when I
> generate a PDF, it comes up blank. I also try running from the command
> line and I also get a blank PDF. It's really strange, when I installed
> the first time (into the default location) and I ran from command line,
> I got it to work with "wkhtmltopdf www.google.com goof.pdf" but it
> hasn't worked since. I have a new MacBook, running rvm with ruby 1.8.7
> and rails 3.
>
> Any thoughts you have would be greatly appreciated. I'm wondering if I
> somehow need to do a complete delete after the various attempts at
> installation, but I don't see anything else to delete aside from the
> wkhtmltopdf file in use/local/bin or the rvm directory. Have either of
> you had to install the 64 bit version?
>
> Thanks,
> Nick
--
Posted via http://www.ruby-forum.com/.
Thanks for replying guys,
I tried to revert back to my system Ruby (out of RVM) and installing
pdfkit via Gem install. Then in installed wkhtmltopdf with pdfkit as
stated above. It runs from the command line, but it still creates a
blank pdf. It's funny, the pdfs open but there is just no content. I'm
stumped.
:) Yep... it should go without saying... but that seems to be exactly
what my problem is. Go figure. I'm still having an error issue inside
Rails, but I think that has something to do with the configuration.
--
#pdfkit
config.middleware.use "PDFKit::Middleware", :print_media_type =>
true
PDFKit.configure do |config|
config.wkhtmltopdf =
'/Users/conor/.rvm/gems/ruby-1.9.2-p0/bin/wkhtmltopdf'
end
This if you want to use PDFKit as rack middleware
Nick Burdick wrote in post #965213:
In my application.rb file I have put this:
config.middleware.use PDFKit::Middleware
PDFKit.configure do |config|
config.wkhtmltopdf = '/usr/local/bin/wkhtmltopdf'
end
Now this is SUPPOSED to allow me to add a .pdf extension to my URL's to
get a PDF version of the page, however, when I do that, from that point
on I get ALL pages as pdf. ie. if I then click on a link in the PDF, it
generates another pdf file of the next page, etc.
If I try and just go to a page without the PDF, it continues to generate
PDFs until I stop the server.
Anyone else have this problem?
These are the relevant gems installed:
wkhtmltopdf-binary (0.9.5.1)
pdfkit (0.5.0)
wkhtmltopdf 0.9.9