Aventador
Aventador

Reputation: 217

How to generate a pdf from a template with Django?

I want to generate a PDF from my template which has data generated from some calculations and operations.

Upvotes: 0

Views: 1177

Answers (3)

seler
seler

Reputation: 9193

Based on experience I'd say that best way to render PDFs is to render a latex template to a file and then Popen pdfTeX or whatever else you like.

Upvotes: 1

vincent
vincent

Reputation: 6608

Depending on your needs you might want to just use wkhtmltopdf ( http://code.google.com/p/wkhtmltopdf/ ) - or similar - to convert web pages into PDF, because HTML templates are easy. On the other hand, reportlab is the only lib that will allow you to generate PDFs in python ( AFAIK ), and it's super boring and outdated. To be fair, the paid version of reportlab is hopefully better.

Upvotes: 1

Francis Yaconiello
Francis Yaconiello

Reputation: 10919

start here: https://docs.djangoproject.com/en/dev/howto/outputting-pdf/

if you need more docs look here: http://www.reportlab.com/

If your goal is to ouput the html itself into the PDF, you are probably going to run into major issues. templating a PDF with reportlab is very different from HTML/CSS

Upvotes: 1

Related Questions