Engineer in Tokyo

Django template2pdf

This is cool Django application from Yasushi Masuda which allows you to render data to a pdf using trml2pdf.

template2pdf provides a generic view called direct_to_pdf which will render a rml template directly to pdf.

# coding: utf-8

from django.http import HttpResponse
from django_trml2pdf import direct_to_pdf

from django.shortcuts import render_to_response

def myview(request, template_name='trml2pdf/mytemplate.rml'):
    params = {}
    return HttpResponse(
        direct_to_pdf(request, template_name, params),
        mimetype='application/pdf')