Question

I'm wondering myself if there's any template code for make invoices output in pdf with reportlab, I'm developing in Django a platform sales and I need to output some data with a invoice look, I tried further but I didn't find anything, anyone know some resources? I don't care if I need to use another library, of course, for python.

Regards!

Edit:

Finally I found a solution with this package: https://pypi.python.org/pypi/django-invoice if anyone is interested.

Regards!

Was it helpful?

Solution

If you are familiar with HTML/CSS, you can first generate an HTML invoice using django's template, and then use the xhtml2pdf package to convert it into PDF format.

The xhtml2pdf is based on top of Reportlab, html5lib and pyPdf. I've used it before, and it solved my problem.

OTHER TIPS

A Django Invoice Pdf View With Pisa
The pisa library makes outputting PDF from a Django view ridiculously easy. The hardest part is probably getting all the dependencies set up properly since pisa relies on reportlab which is quite a large body of software.

pisa works with templates which are a subset of html and css that pisa knows how to convert to PDF. You can even render these templates using Django's templating system. Here's what a view looks like.

First of all the stuff we need:

from django.http import HttpResponse
from django.shortcuts import render_to_response
from django.template.loader import get_template
from django.template import Context
import ho.pisa as pisa
import cStringIO as StringIO
import logging
import sys

More to come later...

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top