I want to creat a pdf file with django. But I use python 3. Is there already a libary supportign python3? I found reportlab, pisa, html2py... but I think none support python 3. I hope something like html2py is available.
Asked
Active
Viewed 3,165 times
2 Answers
4
EDIT: I just came across Django Easy PDF which is Python 3 compatible and may be more useful:
https://github.com/nigma/django-easy-pdf
Note, however, that as of writing this xhtml2pdf which is a dependency of Django Easy PDF only supports Python 3 if you install the latest beta version with:
pip install --pre xhtml2pdf
WeasyPrint is Python 3 compatible:
It's a great library and is easy enough to integrate with Django. Here's a blog post with some suggestions:

metakermit
- 21,267
- 15
- 86
- 95

keybits
- 4,383
- 2
- 20
- 18
-
The problem with weasyprint is embedding fonts. The server must have them installed and most hosts won't let you. I temporarily switched back to python 2.7 and reportlab due to this issue – Alvaro Jan 23 '14 at 15:55
-
Good point. I still like WeasyPrint but just found 'Django Easy PDF' (see edit above) which looks like a good alternative. – keybits Jan 25 '14 at 18:36
-
6django-easy-pdf depends on xhtml2pdf which is not compatible with python 3 – ChristophLSA Jul 05 '14 at 12:00
-
Weasyprint is the way to go. This worked great for me. – Joost Apr 22 '15 at 23:45
-
1xhtml2pdf added beta support for Python 3. For now you have to install it with `pip install --pre xhtml2pdf`. I updated the answer. – metakermit Mar 29 '17 at 15:05
0
I would rather go for a stack described here using:
wkhtmltopdf
(obtained via apt-get) (info: https://wkhtmltopdf.org/)pip install pdfkit
(info: https://pypi.python.org/pypi/pdfkit)

andilabs
- 22,159
- 14
- 114
- 151