Django view that converts HTML to PDF using webkit - via pdfkit and wkhtmltopdf.
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.
Metadata
Release files for django-pdfkit 0.3.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| django-pdfkit-0.3.1.tar.gz | 12.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| django_pdfkit-0.3.1-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details |
Total release size: 21.0 kB
Release files / django-pdfkit-0.3.1.tar.gz
| Download URL | django-pdfkit-0.3.1.tar.gz |
|---|---|
| Size | 12.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
028428e41d5f734b5f390aa1791b729a12f60ee61409b9f37cf2153737520303
|
|
BLAKE2b-256 checksum How to use checksums |
78f998848b96d71207874a7923d5ab0f1ba06b8e668401a4dfd3980fa76c0715
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / django_pdfkit-0.3.1-py2.py3-none-any.whl
| Download URL | django_pdfkit-0.3.1-py2.py3-none-any.whl |
|---|---|
| Size | 8.8 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
f1c08f705f26d46f6d7df5c730946c28306b6dc5178c8fca527a413429155673
|
|
BLAKE2b-256 checksum How to use checksums |
58d0e9ea1c8d6e6493b248c9891dba95c9c0ee3646922af7aa9fb61b3e8ebf76
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |