MikeKJ
unread,Apr 16, 2012, 7:40:10 AM4/16/12Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to xhtm...@googlegroups.com
Am I missing a dependancy?
from django.template.loader import get_template
from django.template import Context
import cStringIO as StringIO
import ho.pisa as pisa
from sx.pisa3 import pisaDocument
import cgi
from django import forms
def render_to_pdf(request, this_id):
template = get_template('video/reflection.pdf')
this_video = Part.objects.get(pk=this_id)
context_dict = {'this_video': this_video,}
context = Context(context_dict)
html = template.render(context)
result = StringIO.StringIO()
pdf = pisa.pisaDocument(StringIO.StringIO(html.encode("UTF-8")), dest=result, link_callback=fetch_resources )
if not pdf.err:
return HttpResponse(result.getvalue(), mimetype='application/pdf')
return HttpResponse('Error<pre>%s</pre>' % cgi.escape(html))