Skip to main content

A Simpler python wrapper for wkhtmltopdf, inspired by Qoda's python-wkhtmltopdf

Project description


A simple and direct python wrapper for the `wkhtmltopdf
lib <>`__ inspired by inspired
by `Qoda's
python-wkhtmltopdf <>`__



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


wkhtmltopdf (Linux)

1. Install Fonts:

.. code:: bash

$ sudo apt-get install xfonts-100dpi xfonts-75dpi xfonts-scalable xfonts-cyrillic

2. Install wkhtmltopdf

goto for the latest release

wkhtmltopdf (OSX)

or goto for the latest release

wkhtmltopdf-wrapper (Any Platform)

1. PIP:

.. code:: bash

$ pip install wkhtmltopdf-wrapper


.. code:: bash

$ pip install git+

2. Development:

.. code:: bash

$ git clone
$ cd wkhtmltopdf-wrapper
$ virtualenv .
$ pip install -r requirements.pip


the option\_string would be sent to the wkhtmltopdf command line in
exactly the same shape. so the options can be anything as long as the
wkhtmltopdf supports. check its
`usage <>`__. This lib is
just as simple as that. If anything goes wrong, just check the doc. If
the command execute ok with wkhtmltopdf dircetly, this wrapper should
work too.

As I check
`qoda/python-wkhtmltopdf <>`__,
where this repo forked from, it tried to prase args. But it only include
a small set of the arguments the command supports. Furthermore, it set
default values to this set of arguments and pass them all to the
command. For me, it is totally unnecessary and even mistakeful. There is
default setting setup and doc in the command. Some arugments may not
even work together, as ``--page-size`` and ``--page-height``,
``--page-width``. So my solution is just pass the option in as a string,
Lazy, flexible and effective.

from class:

.. code:: python

from wkhtmltopdfwrapper import WKHtmlToPdf

wkhtmltopdf = WKHtmlToPdf('-T 20 -B 20 -g --zoom 1.5')
# option_string

wkhtmltopdf.render('', '~/example.pdf')
# source url, output file path

from method:

.. code:: python

from wkhtmltopdfwrapper import wkhtmltopdf
wkhtmltopdf('', '~/example.pdf', '-T 20 -B 20 -g --zoom 1.5')

from commandline (installed):

.. code:: bash

$ python -m wkhtmltopdfwrapper.__init__ ~/example.pdf -T 20 -B 20 -g --zoom 1.5


- Jonathan Bydendyk (
- Weihong Guan (

Project details

Download files

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

Source Distribution

wkhtmltopdf-wrapper-0.3.3.tar.gz (3.6 kB view hashes)

Uploaded Source

Built Distribution

wkhtmltopdf_wrapper-0.3.3-py2.py3-none-any.whl (5.4 kB view hashes)

Uploaded Python 2 Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page