Ian Lewis
Ian Lewis is a web developer living in Tokyo Japan. His current interests are in Django, python, alternative databases and rapid web application development. About Me...

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')
このエントリーを含むはてなブックマーク はてなブックマーク - Django template2pdf

blog comments powered by Disqus