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.49k
    Comment on it

    This library is used to create pdf from html.

    Steps to install:

    #Install wkhtmltopdf library in ruby by using below command:

    1. apt-get install wkhtmltopdf

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

    1. which wkhtmltppdf

    Once wkhtmltopdf installed then install Pdfkit

    1. gem install pdfkit

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

    1. **PDFKit.configure do |config|
    2. config.wkhtmltopdf = '/usr/bin/wkhtmltopdf'
    3. config.default_options = {
    4. :page_size => 'A4',
    5. :print_media_type => true
    6. }
    7. 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:
    1. login as root
    2. wget http://wkhtmltopdf.googlecode.com/files/wkhtmltopdf-0.9.9-static-amd64.tar.bz2
    3. tar xvjf wkhtmltopdf-0.9.9-static-amd64.tar.bz2
    4. mv wkhtmltopdf-amd64 /usr/local/bin/wkhtmltopdf
    5. chmod +x /usr/local/bin/wkhtmltopd

    Again run this command

    1. which wkhtmltppdf #to find the path. This path need to add in in pdfkit.rb[in initializers folder]
    2. 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
Reset Password
Fill out the form below and reset your password: