Skip to content
A simple python wrapper for the wkhtmltopdf lib.
Find file
Latest commit bc1489b @dougk7 dougk7 Update link to wkhtmltopdf in README
Update the link to point to the github repository of wkhtmltopdf. It used to be hosted on



A simple python wrapper for the wkhtmltopdf lib (



  • Linux 32/64 or OSX only (Windows is not supported at this stage)
  • Xvfd
  • wkhtmltopdf
  • python 2.5+


wkhtmltopdf (Linux)

  1. Install Xvfd:

    $ sudo apt-get install xvfb
  2. Install Fonts:

    $ sudo apt-get install xfonts-100dpi xfonts-75dpi xfonts-scalable xfonts-cyrillic
  3. Install wkhtmltopdf:

    $ sudo apt-get install wkhtmltopdf

wkhtmltopdf (OSX)

  1. Install wkhtmltopdf:

    $ brew install wkhtmltopdf

python-wkhtmltopdf (Any Platform)

  1. Development:

    $ git clone
    $ cd python-wkhtmltopdf
    $ virtualenv .
    $ pip install -r requirements.pip
  2. PIP:

    $ pip install git+
    or from pypi
    $ pip install python-wkhtmltopdf


Simple Usage::

  1. Use from class:

    from wkhtmltopdf import WKHtmlToPdf
    wkhtmltopdf = WKHtmlToPdf(
  2. Use from method:

    from wkhtmltopdf import wkhtmltopdf
    wkhtmltopdf(url='', output_file='~/example.pdf')
  3. Use from commandline (installed):

    $ python -m wkhtmltopdf.main ~/example.pdf
  4. Use the api (installed):

    $ python -m wkhtmltopdf.api &
    $ wget http://localhost:8888/?

Required Arguments:

  • url - the url to convert to pdf
  • output_file - the pdf file that you want to create

Optional Arguments:

  • enable-plugins (default: True)
  • disable-javascript (default: False)
  • no-background (default: False)
  • grayscale (default: False)
  • orientation (default: Portrait)
  • dpi (default: 100)
  • username (default: None)
  • password (default: None)
  • margin-bottom (default: 10)
  • margin-top (default: 10)
  • margin-left (default: 10)
  • margin-right (default: 10)
  • disable-smart-shrinking (default: False)
Something went wrong with that request. Please try again.