Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Install pdfkit and wkhtmltopdf library on Ubuntu 12.04/ruby

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 1.08k
    Comment on it

    This library is used to create pdf from html.

    Steps to install:

    #Install wkhtmltopdf library in ruby by using below command:

    apt-get install wkhtmltopdf
    

    #Use below command to find the path. This path need to add in in pdfkit.rb[in initializers folder]

    which wkhtmltppdf
    

    Once wkhtmltopdf installed then install Pdfkit

        gem install pdfkit
    

    If pdfkit.rb is not present in initializers folder then create it with following content

     **PDFKit.configure do |config|
    config.wkhtmltopdf = '/usr/bin/wkhtmltopdf'
    config.default_options = {
    :page_size => 'A4',
    :print_media_type => true
    }
    end**
    

    Note: If you get any error like [BROKEN PIPE] Then
    please follow following steps:

    1. remove wkhtmltopdf
    2. then install wkhtmltopdf with following steps:
      login as root  
      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/wkhtmltopd
    

    Again run this command

      which wkhtmltppdf          #to find the path. This path need to add in in pdfkit.rb[in initializers folder]
      Set path in pdfkit.rb[in initializers folder]
    

    This will resolve the above problem

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: