Skip to content Skip to sidebar Skip to footer

Jinja-like For Pdf In Python

I am looking for the best accurate tool for PDF in Python that works like Jinja does for HTML. What are your suggestions?

Solution 1:

As answered by jbochi, ReportLab is the foundation for almost all Python projects that generate PDF.

But for your needs you might want to check out Pisa / xhtml2pdf. You would generate your HTML with a Jinja template and then use Pisa to convert the HTML to PDF. Pisa is built on top of ReportLab.

Edit: another option I'd forgotten about is wkhtmltopdf

Solution 2:

Have a look at ReportLab Toolkit.

You can use templates only with the commercial version, though.

Solution 3:

Solution 4:

I had exactly the same requirement as the OP. Unfortunately WeasyPrint wasn't a viable solution, because I needed very exact positioning and barcode support. After a few days of work I finished a reportlab XML wrapper with Jinja2 support.

The code can be found on GitHub including an example XML wich generates the following PDF.

Solution 5:

What about python/jinja to rst/html and html/rst to pdf using either rst2pdf or pandoc.

Both of these have worked well for me but. like plaes, I may try Weasyprint in the future.

Post a Comment for "Jinja-like For Pdf In Python"