Skip to content

alexhayes/django-pdfkit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Aug 15, 2017
02774ae · Aug 15, 2017

History

30 Commits
Aug 15, 2017
Oct 27, 2016
Oct 28, 2016
Oct 28, 2016
Oct 27, 2016
Oct 27, 2016
Aug 7, 2017
Aug 15, 2017
Oct 27, 2016
Oct 27, 2016
Oct 27, 2016
Aug 15, 2017
Oct 28, 2016
Oct 27, 2016
Oct 27, 2016
Oct 27, 2016
Oct 27, 2016
Oct 27, 2016
Oct 27, 2016
Aug 7, 2017

Repository files navigation

Django PDFKit

Django view that converts HTML to PDF using webkit - via pdfkit and wkhtmltopdf.

Build Status Code Health Code Coverage Documentation Status Latest Version Supported Python versions Downloads

Prerequisites

You need to install wkhtmltopdf.

The versions in Debian/Ubuntu repositories (installed using apt-get install wkhtmltopdf) have reduced functionality and you will most likely want to install one of the stable binaries provided at http://wkhtmltopdf.org/downloads.html which provide increased functionality (headless, patched Qt, better rendering support).

Installation of the pre-compiled binaries on Ubuntu is as simple as;

wget http://download.gna.org/wkhtmltopdf/0.12/0.12.3/wkhtmltox-0.12.3_linux-generic-amd64.tar.xz
tar -xf wkhtmltox-0.12.3_linux-generic-amd64.tar.xz
sudo cp -r wkhtmltox/* /usr/

Install

pip install django-pdfkit

Usage

Simply use the class based PDFView which is a drop in replacement for TemplateView.

# urls.py
from django_pdfkit import PDFView

...
url(r'^my-pdf/$', PDFView.as_view(template_name='my-pdf.html'), name='my-pdf'),
...

Then in your browser goto http://localhost:8000/my-pdf/ and it will magically render as a PDF.

See the docs for more information.

Author

Alex Hayes <alex@alution.com>