4

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.

2 Answers 2

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:

http://weasyprint.org/

It's a great library and is easy enough to integrate with Django. Here's a blog post with some suggestions:

http://ampad.de/blog/generating-pdfs-django/

5
  • 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, 2014 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, 2014 at 18:36
  • 6
    django-easy-pdf depends on xhtml2pdf which is not compatible with python 3 Jul 5, 2014 at 12:00
  • Weasyprint is the way to go. This worked great for me.
    – Joost
    Apr 22, 2015 at 23:45
  • 1
    xhtml2pdf 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, 2017 at 15:05
0

I would rather go for a stack described here using:

Not the answer you're looking for? Browse other questions tagged or ask your own question.