Getting started

Introduction

As a developer I have had problems in PDF generation in the past, and I thought someone out there needs a helping hand.

Sendpdf is an app that enables you to generate PDF documents from predefined html templates. Design your PDF with the tools that we all love and know how to use perfectly well: HTML and CSS.

Intalling Django-sendpdf

  1. Install django-sendpdf:
$ pip install django-sendpdf
  1. Install wkhtmltopdf:
  • Debian/Ubuntu:
$ sudo apt-get install wkhtmltopdf

Warning! Version in debian/ubuntu repos have reduced functionality (because it compiled without the wkhtmltopdf QT patches), such as adding outlines, headers, footers, TOC etc. To use this options you should install static binary from wkhtmltopdf site or you can use this script.

  • Windows and other options: check wkhtmltopdf homepage for binary installers
  1. Add “sendpdf” to your INSTALLED_APPS setting like this:

    INSTALLED_APPS = (
        ...
        'sendpdf',
    )
    
  2. In your Django settings add the location of wkhtmltopdf, if you download the binary or follow the above guide then the location would be ‘/usr/local/bin/wkhtmltox/bin/wkhtmltopdf’ which you don’t have to define its PATH explicitly as below, like this:

    WKTHMLTOPDF_PATH = "wkhtmltopdf/path/here"
    
  1. Include the sendpdf URLconf in your project urls.py like this:

    url(r'^sendpdf/', include('sendpdf.urls', namespace='sendpdf')),
    
  2. Test if the app can run without any errors:

    python manage.py test sendpdf
    

sendpdf.topdf.py

sendpdf.views.py