Issues with Arabic Text Direction and Encoding in PDF using mPDF with Laravel

34 views Asked by At

I'm using the mPDF package in a Laravel project to generate PDFs from views, specifically for rendering Arabic text. My goal is to include Arabic text alongside left-to-right (LTR) characters (like parentheses) in the generated PDFs. However, I'm encountering an issue where the text direction and encoding seem to be mishandled, leading to jumbled and reversed Arabic text in the output PDF.

I'm trying to display the string "الاسم الأول (عربي)" in the PDF. However, the output in the PDF looks like this: "‫)ﻋﺮﺑﻲ‬ ‫اﻷول‬ ‫)اﻻﺳﻢ".

What's the correct way to handle text direction for mixed Arabic and LTR content (like parentheses) to ensure they are displayed correctly in the generated PDF?

1

There are 1 answers

0
Zain ul Abideen On BEST ANSWER

The Arabic thing starts from right to left just add

dir="rtl"