Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (
Help us improve Python packaging - Donate today!

Wkhtmltopdf wrapper

Project Description


A simple python wrapper for wkhtmltopdf forked from python-wkhtmltopdf



  • 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 html2pdf
    $ virtualenv .
    $ pip install -r requirements.pip
  2. PIP:

    $ pip install git+
    or from pypi
    $ pip install html2pdf


Simple Usage::

  1. Render a URL:

    from wkhtmltopdf import HTMLURLToPDF
    make_pdf = HTMLURLToPDF(
  2. Render a HTML string:

    from html2pdf import HTMLToPDF
    HTML = """
        <!DOCTYPE html>
            <h1>Hello World</h1>
    h = HTMLToPDF(HTML, self.output_file)

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)


Forked from wkhtmltopdf - Jonathan Bydendyk (

Release History

This version
History Node


Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, Size & Hash SHA256 Hash Help File Type Python Version Upload Date
(5.1 kB) Copy SHA256 Hash SHA256
Source None Aug 13, 2014

Supported By

Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Kabu Creative Kabu Creative UX & Design Google Google Cloud Servers Fastly Fastly CDN StatusPage StatusPage Statuspage DigiCert DigiCert EV Certificate