How to Install wkhtmltopdf?

2019-05-26 06:25发布

问题:

Now i am working on rails 3.0.0.i am using Ubuntu 11.10 ,64 bit os.i want to install wkhtmltopdf.please tell me the static version of wkhtmltopdf.

回答1:

Installing wkhtmltopdf

on Ubuntu Linux machine

  1. First check os is 32 bit or 64 bit by using following command

    Try uname -m. It seems like the uname -m actually gives x86_64 when it is an kernel 64 bits

  2. Run following command

    sudo apt-get install openssl build-essential xorg libssl-dev libxrender-dev
    
  3. Then run following command

    sudo apt-get install wkhtmltopdf
    
  4. Based on OS download wkhtmltopdf package from following site

    http://code.google.com/p/wkhtmltopdf/downloads/list

    OR

    wget http://wkhtmltopdf.googlecode.com/files/wkhtmltopdf-0.9.9-static-i386.tar.bz2
    

    (wkhtmltopdf-0.9.9-static-i386.tar.bz2 is a stable release for wkhtmltopdf )

  5. Then extract using command

    tar xvjf wkhtmltopdf-0.9.9-static-i386.tar.bz2
    
  6. Then move extracted DIR to usr/local/bin folder

    sudo mv wkhtmltopdf-i386 /usr/local/bin/wkhtmltopdf
    
  7. Check wkhtmltopdf is install or not using following command

    which wkhtmltopdf
    wkhtmltopdf –help
    

Installing wkhtmltopdf on MacOs

brew install Caskroom/cask/wkhtmltopdf


回答2:

Another way to use official binaries within Rails is adding the following line to your Gemfile:

gem 'wkhtmltopdf-installer'

This way the official binaries from http://wkhtmltopdf.org will be downloaded and added to your bundle during bundle install phase.



回答3:

I encountered this problem this morning.

Before you do anything, please check out: https://github.com/pdfkit/pdfkit/wiki/Installing-WKHTMLTOPDF

  1. Download a binary edition of wkhtmltopdf at http://code.google.com/p/wkhtmltopdf/downloads/list

  2. Decompress the package.

  3. Copy the file like wkhtmltopdf-i386 to /usr/local/bin/ & /opt/ (also you could make soft link).

  4. That's done.

Good luck.