global name 'fetch_resources' is not defined

107 views
Skip to first unread message

MikeKJ

unread,
Apr 16, 2012, 7:40:10 AM4/16/12
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))

Philippe Raoult

unread,
Apr 16, 2012, 7:42:04 AM4/16/12
to xhtm...@googlegroups.com
you need to implement the link callback (fetch_resources)

> --
> You received this message because you are subscribed to the Google Groups
> "Pisa XHTML2PDF Support" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/xhtml2pdf/-/fTm-LnBP7tYJ.
> To post to this group, send email to xhtm...@googlegroups.com.
> To unsubscribe from this group, send email to
> xhtml2pdf+...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/xhtml2pdf?hl=en.

Reply all
Reply to author
Forward
0 new messages