I am using Django xhtml2pdf to generate PDF, and it not supporting Arabic text I tried all possible ways which are suggested but still no luck
<style>
@import url(https://fonts.googleapis.com/css?family=Markazi+Text);
.markazi-text{font-family:'Markazi Text',serif}
*{
font-size: 12px;
padding: 0px;
margin: 0px;
}
table{
border: 1px solid #000;
margin-bottom: 5px;
}
table tr th{
padding-top: 5px;
-pdf-word-wrap: CJK;
padding: 5px;
}
table tr td{
padding-top: 5px;
padding-left: 5px;
width: auto;
word-break: break-all;
padding: 5px;
-pdf-word-wrap: CJK;
}
table tr td p{
word-break: break-all;
}
p{
margin: 0px;
font-family:'Markazi Text';
}
.vendor-sec{
border: 1px solid #000;
width: 150px;
padding: 5px;
margin-bottom: 15px;
}
</style>
Django code
template_path = 'pdf.html'
response = HttpResponse(content_type='application/pdf')
response['Content-Disposition'] = 'attachment; filename="declaration.pdf"'
html = render_to_string(template_path, data)
result = io.BytesIO()
pdf = pisa.pisaDocument(io.BytesIO(html.encode("UTF-8")), dest=result,encoding='UTF-8')
content = result.getvalue()
encoded = base64.b64encode(content)
encoded = encoded.decode('utf-8')
I tried all below solutions
On HTML I can see arabic text but when I try to convert this HTML to pdf the its show blocks