79834515

Date: 2025-12-01 08:46:59
Score: 1
Natty:
Report link

It does not support:

So even though your string is correct in Python, FPDF draws characters as isolated shapes from left to right.

To correctly render Arabic in FPDF, you must reshape + reorder the text manually before passing it to FPDF.

You need two Python packages:

pip install arabic-reshaper python-bidi

Working Example (Python + FPDF)

from fpdf import FPDF

import arabic_reshaper

from bidi.algorithm import get_display

# your Arabic text

text = "هذا نص تجريبي باللغة العربية."

# 1. reshape letters

reshaped_text = arabic_reshaper.reshape(text)

# 2. reorder text for RTL

bidi_text = get_display(reshaped_text)

pdf = FPDF()

pdf.add_page()

# Add an Arabic TTF font

pdf.add_font('Arial', '', 'arial.ttf', uni=True)

pdf.set_font('Arial', size=16)

pdf.write(10, bidi_text)

pdf.output("arabic_test.pdf")

Reasons:
  • Long answer (-0.5):
  • No code block (0.5):
  • Low reputation (1):
Posted by: Hesham Essam