Ajout export pdf des heures supplémetnaires
This commit is contained in:
15
collabs/list_pdf_export.py
Normal file
15
collabs/list_pdf_export.py
Normal file
@@ -0,0 +1,15 @@
|
||||
from django.http import HttpResponse
|
||||
from django.template.loader import get_template
|
||||
from xhtml2pdf import pisa
|
||||
|
||||
|
||||
def render_to_pdf(template_src, context_dict={}):
|
||||
template = get_template(template_src)
|
||||
html = template.render(context_dict)
|
||||
response = HttpResponse(content_type='application/pdf')
|
||||
pdf_status = pisa.CreatePDF(html, dest=response)
|
||||
|
||||
if pdf_status.err:
|
||||
return HttpResponse('Some errors were encountered <pre>' + html + '</pre>')
|
||||
|
||||
return response
|
Reference in New Issue
Block a user