Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 484
Mamane Avatar asked Jan 14 '10 14:01

Mamane


People also ask

Can you use Python in Jinja?

What might be worth knowing is the fact that you can pass a Python function into your Jinja templates. Doing this can greatly improve the readability of your template as well as allow you to handle more complicated scenario's.

Can Python generate PDF?

FPDF is a Python class that allows generating PDF files with Python code. It is free to use and it does not require any API keys. FPDF stands for Free PDF.

What is the difference between Jinja and Jinja2?

Jinja, also commonly referred to as "Jinja2" to specify the newest release version, is a Python template engine used to create HTML, XML or other markup formats that are returned to the user via an HTTP response.


1 Answers

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

like image 100
Van Gale Avatar answered Oct 06 '22 22:10

Van Gale