A simple django app to generate PDF documents.

Note : If you are using buildout, don’t forget to put pdfutils in your eggs section or else the django-pdfutils dependencies wont be installed.

Example report

Reports are basically views with custom methods and properties.

# -*- coding: utf-8 -*- from django.contrib.auth.models import User from django.core.urlresolvers import reverse from django.utils.translation import ugettext as _ from pdfutils.reports import Report from pdfutils.sites import site class MyUserReport ( Report ): title = _ ( 'Users' ) template_name = 'myapp/reports/users-report.html' slug = 'users-report' orientation = 'portrait' def get_users ( self ): return User . objects . filter ( is_staff = True ) def get_styles ( self ): """ It is possible to add or override style like so """ self . add_styles ( 'myapp/css/users-report.css' ) return super ( AccountStatementReport , self ) . get_styles () def filename ( self ): """ The filename can be generated dynamically and translated """ return _ ( 'Users-report- %(count)s .pdf' ) % { 'count' : self . get_users () . count () } def get_context_data ( self ): """ Context data is injected just like a normal view """ context = super ( AccountStatementReport , self ) . get_context_data () context [ 'user_list' ] = self . get_users () return context site . register ( MyUserReport )

The slug should obviously be unique since it is used to build the report URL.