Skip to main content

Errno::ENOENT: No such file or directory


HTML to PDF conversion is very easy in rails and pdfkit will be useful in this case, wkhtmltopdf tool will be supporting tool so you can easily convert an html to pdf. 

In my experience I used the following steps:

gem install pdfkit -v 0.5.0
gem install wkhtmltopdf -v 0.1.2
gem install wkhtmltopdf-binary

Some times this sequence will not work, so I use the following as per the instruction from https://github.com/pdfkit/pdfkit/wiki/Installing-WKHTMLTOPDF

Be careful to download the appropriate wkhtmltopdf tar ball, it depends on your os architecture, like i386 or 64


Try to convert html to pdf after restarting your web servers. 

If you get any error like: Errno::ENOENT: No such file or directory then I have a straightforward method and it is very simple too.

Uninstall the gem "wkhtmltopdf"

gem uninstall wkhtmltopdf 

then do the above things again, that is:

wget http://wkhtmltopdf.googlecode.com/files/wkhtmltopdf-0.9.9-static-amd64.tar.bz2
tar xvjf wkhtmltopdf-0.9.9-static-amd64.tar.bz2
mv wkhtmltopdf-amd64 /usr/local/bin/wkhtmltopdf
chmod +x /usr/local/bin/wkhtmltopdf

Restart your web servers, it should work.

Comments

  1. hi!
    i'm from mexico

    same thing happened to me, but my error was in layout of render_to_string:


    html1 = render_to_string(:template => "/file.html.erb", :layout => 'file', :locals => { :id => @object.id })
    kit1 = PDFKit.new(html1,:orientation=>'Portrait')
    kit1.stylesheets << "#{Rails.root}/file.css"
    kit1 = kit1.to_file("#{Rails.root}/public/file#{@object.id}_file.pdf")

    next change:

    html1 = render_to_string(:template => "/file.html.erb", :layout => false, :locals => { :id => @object.id })
    kit1 = PDFKit.new(html1,:orientation=>'Portrait')
    kit1.stylesheets << "#{Rails.root}/file.css"
    kit1 = kit1.to_file("#{Rails.root}/public/file#{@object.id}_file.pdf")

    ReplyDelete
  2. hi Dulce,

    Is it working fine after your "next change" ? otherwise let me know what the exact error are you receiving.

    Best,
    Kannan

    ReplyDelete

Post a Comment

Popular posts from this blog

Lighttpd with fastCGI for ROR 1.2.1

Lighttpd Installation: As of now (18-Feb-2011) the version 1.4.28 is the current version of lighttpd, which we need yo downloaded from  http://www.lighttpd.net/ tar -zxvf lighttpd-1.4.28.tar.gz cd lighttpd-1.4.28 ./configure ./configure --with-openssl Look at lighttpd is automatically mapped at /usr/local/sbin/lighttpd , so try to execute the version check command and the output will be very similar as: [root@kannan ~]# /usr/local/sbin/lighttpd -v lighttpd/1.4.28 (ssl) - a light and fast webserver Build-Date: Feb 17 2011 16:37:02 Then, note that there might be a new directory called /etc/lighttpd/ which will contains a default configuration file called "lighttpd.conf" This is the file which will contains the information about how  (ROR based) web application is going to act along with script/server. This file is same as webrick/config.rb  for Webricks, httpd.conf for Apche, web.config for IIS etc., Note:  The file <RAI...

Redis & nginx configuration for websocket/actionCable

Start redis server => redis-server redis console => redis-cli view available databases => config get databases pubsub channels global* pubsub channels global_notification_2 pubsub channels global_notification pubsub channels * => Lists all the available channels pubsub numsub global_notification_2 => returns the number of subscribers From unix command line directly redis-cli PUBSUB CHANNELS redis-cli PUBSUB NUMSUB global_notification_2 [root@api prod-openmednet-api]# redis-cli PUBSUB CHANNELS 1) "_action_cable_internal" 2) "global_notification_2" [root@api prod-openmednet-api]# redis-cli PUBSUB CHANNELS global_notification_2 1) "global_notification_2" [root@api prod-openmednet-api]# redis-cli PUBSUB NUMSUB global_notification_2 1) "global_notification_2" 2) (integer) 2 NGINX configuration:  worker_processes   auto; worker_rlimit_nofile 500000;  #=> refer RLIM...