Reputation: 41
I've generated a pdf using Django-pisa.. the PDF content is taken from database which is in the correct alignment but can't get it done right on the PDF....
I've used:
filename = "/home/anoop/DjangoCodes/hello.pdf"
c = '''<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<style type="text/css">
@font-face {font-family: code2000;src: url(dhivehi.otf.ttf);}
html {font-family: code2000;dir: rtl;unicode-bidi:bidi-override;}
</style>
</head><body><div dir='rtl'>%s</div></body></html>''' % content_text
print c
pdf = pisa.CreatePDF(c,file(filename, "wb"))
if not pdf.err:
pisa.startViewer(filename)
content_text contains the dhivehi text..
Example : content_text: އެގޮތުން އައްޑޫގެ މަރަދޫ އާއި މަރަދޫފޭދޫ އާއި ފޭދޫ އަށްވެސް އުދަ އަރާފައިވާ ކަމަށް
text in pdf: ށަމަކ ާވިއަފާރައ ަދުއ ްސެވްށައ ޫދޭފ ިއާއ ޫދޭފޫދަރަމ ިއާއ ޫދަރަމ ެގޫޑްއައ ްނުތޮގެއ
Upvotes: 2
Views: 508
Reputation: 1219
I faced similar problem and I solved it by just changing the fonts which can display these type of characters (e.g. Arial Unicode MS, DejaVuSerif).
Edit:
I was using mpdf library (unicode support) which is written in PHP for dynamic PDF creation with russian language (Cyrillic) and faced similar problem. At that time I was using arial font and then I switched to ArialUni,DejaVuSerif fonts which solved the problem.
Upvotes: 2