I have tried to write Bangla font to create a pdf file using pyfpdf in python. I have written the bangla word using Unicode Avro Bangla Phonetic Font. But when I use pdf.cell command to write the bangla word in the pdf file, the letters in the word gets interchanged. For example, if I try to write the word "করিম", it gets written in the pdf file as "করমি". Here is the code:

from fpdf import FPDF

pdf = FPDF()
pdf.add_page()
pdf.add_font('DejaVu Sans', '', r'C:\Users\PWD-PD-5\Desktop\kalpurush.ttf', uni = True)
pdf.set_font('DejaVu Sans', size = 20)

a = str("করিম") 

pdf.cell (200, 10, '%s'%a, ln=1, align = "C")

pdf.output ("Bangla.pdf")

The Word "করিম" is shown like the picture below, in the output. Please help to solve the problem.

"করিম"

0

There are 0 best solutions below