Add the invoice template
This commit is contained in:
parent
030a0cd501
commit
5bb0c4cdda
24 changed files with 462 additions and 96 deletions
|
|
@ -1,19 +0,0 @@
|
|||
import os
|
||||
from io import BytesIO
|
||||
from django.http import HttpResponse
|
||||
from django.template.loader import get_template
|
||||
from django.conf import settings
|
||||
|
||||
from xhtml2pdf import pisa
|
||||
|
||||
def render_to_pdf(template_src, context_dict={}):
|
||||
template = get_template(template_src)
|
||||
html = template.render(context_dict)
|
||||
result = BytesIO()
|
||||
# pdf = pisa.pisaDocument(BytesIO(html.encode("ISO-8859-1")), result)
|
||||
links = lambda uri, rel: os.path.join(settings.MEDIA_ROOT, uri.replace(settings.MEDIA_URL, ''))
|
||||
pdf = pisa.pisaDocument(BytesIO(html.encode("ISO-8859-1")),dest=result)
|
||||
|
||||
if not pdf.err:
|
||||
return HttpResponse(result.getvalue(), content_type='application/pdf')
|
||||
return None
|
||||
Loading…
Add table
Add a link
Reference in a new issue