Skip to content

Instantly share code, notes, and snippets.

View tjzango's full-sized avatar
🎯
Focusing

Haruna Tijjani Zango tjzango

🎯
Focusing
View GitHub Profile
@tjzango
tjzango / python
Created September 19, 2019 10:12
Render to pdf
# Util .py
from io import BytesIO
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)
result = BytesIO()