I would like to convert an HTML string containing CSS (preferable CSS3 using flex and grid etc) into PDF. I mPDF for my PHP projects but I am looking for a python equivalent (open-source) for my Django 4.2 based project.
I can’t say I’ve done this myself, but a quick Google of
HTML to PDF in Python turns up this SO question with a number of viable answers:
It sounds like of those options, Weasyprint might be the way to go as it is well maintained, sophisticated and has detailed docs (the top-rated option, PDFkit which uses webkit to render the HTML to PDF, is deprecated and has not been maintained in a couple years, and has little in the way of docs).
Majority don’t support latest CSS3 features like flex and grid.
xhtml2pdf, WeasyPrint and ReportLab seem to be the most popular.
I need to compare these 3 and select.