django-orchestra-test/orchestra/apps/bills/actions.py

14 lines
471 B
Python
Raw Normal View History

2014-08-20 18:50:07 +00:00
from django.http import HttpResponse
2014-08-29 12:45:27 +00:00
from orchestra.utils.system import run
2014-08-20 18:50:07 +00:00
2014-08-19 18:59:23 +00:00
def generate_bill(modeladmin, request, queryset):
2014-08-20 18:50:07 +00:00
bill = queryset.get()
bill.close()
2014-08-29 16:13:34 +00:00
# return HttpResponse(bill.html)
pdf = run('xvfb-run -a -s "-screen 0 640x4800x16" '
'wkhtmltopdf --footer-center "Page [page] of [topage]" --footer-font-size 9 - -',
stdin=bill.html.encode('utf-8'), display=False)
2014-08-29 12:45:27 +00:00
return HttpResponse(pdf, content_type='application/pdf')