while converting Hindi words in HTML to pdf by using the xhtml2pdf library in Django projects I am getting some coded words on how to convert in the correct way?
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("UTF-8")), result, encoding='UTF-8')
if not pdf.err:
return HttpResponse(result.getvalue(), content_type='application/pdf')
return None