Created
March 8, 2011 22:12
-
-
Save byroot/861196 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ho.pisa as pisa | |
from django.template import loader | |
from django.http import HttpResponse | |
def render_to_pdf(*args, **kwargs): | |
response = HttpResponse('', mimetype='application/pdf') | |
response['Content-Disposition'] = 'attachment; filename=%s' % kwargs.pop('filename', 'something.pdf') | |
document = loader.render_to_string(*args, **kwargs) | |
print document | |
pisa.CreatePDF(document, response) | |
return response |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment