Home > Back-end >  How to print Arabic and English text together using Python's fpdf library
How to print Arabic and English text together using Python's fpdf library

Time:10-23

pdf.multi_cell(w=150, h=5, txt="تمانتمانتمانتمانتم English Letters") 

"English Letters" is rendered as a row of rectangles in the output:

enter image description here

I also tried using arabic_reshaper Example code snippet:

import arabic_reshaper
from bidi.algorithm import get_display
reshaped_text = arabic_reshaper.reshape(text)
bidi_text = get_display(reshaped_text)
pdf.set_xy(9, 132)
pdf.multi_cell(w=150, h=5, txt=bidi_text)

...but it didn't work. Are there any other possible ways to make it work?

CodePudding user response:

The maintainer of the FPDF library answered my question in respective discussion forum

checkout the solution and the desired outcome attached in the post: https://github.com/PyFPDF/fpdf2/discussions/583

  • Related