I generate PDF files in my django app by making something like:
context = Context({'data':data_object, 'MEDIA_ROOT':settings.MEDIA_ROOT})
html = template.render(context)
result = StringIO.StringIO()
pdf = pisa.pisaDocument(StringIO.StringIO(html.encode('UTF-8')), result)
if not pdf.err:
response = HttpResponse( result.getvalue() )
response['Content-Type'] = 'application/pdf'
response['Content-Disposition'] = 'attachment; filename="%s.pdf"'%(title)
return response
And it works great, when users wants to download the PDF file. However, I am in need to attach this PDF in email message. Thats why I would need to get content of this PDF. I can't find anything in xhtml2pdf docs. Could you help me in resolving it?