Arabic , PDF And Joomla!
Update August 2nd, 2007: I will be releasing this hack in the following few days Insha’Allah.
Update September 4th, 2007: I’ve released the code on SourceForge you can access it by checking out the CVS there.
The project url: http://sourceforge.net/projects/arabic-tcpdf
CVS Checkout command
It is a known fact that Joomla! 1.0.x can export content into pdf format, however, this feature doesn’t seem to be working well when used to export Arabic content to pdf format, either windows-1256 or UTF-8 encoded.
To address this issue, The guys at the Joomla! core has moved to TCPDF library to export pdf files, this library has support for images and more importantly UTF-8 which means it can -theoritaclly speaking- be used to handle pretty much ANY langauge, This is true for many Left-To-Right languages, however, For a Right-To-Left language like Arabic the situation is quite different I’ll try to brief the problem here.
First off, Arabic is a complex script language, This means that putting letters side by side is not just enough, A typical Arabic letter has different combining forms based on its context in the word.
For a PDF generator to handle Arabic text correctly it must pre-process the input text and determine which combining form to render “Shaping” ,otherwise the text will appear as separated Arabic letters as shown in the following image, So far Joomla! 1.5 PDF engine doesn’t take that in consideration which means any Arabic text exported by Joomla! will appear as separated letters.
To tackle this issue I’m using a class called ArGlyphs by Khaled Al-Shamaa.
Quoting from the project description on phpclasses.org
The class takes as input Arabic text encoded using Windows-1256 character set and performs Arabic glyph joining to output a string encoded using UTF-8.
So basically this class will fix this shaping problem , I had to modify it a bit to accept UTF-8 without messing it up, I used the phpUTF8 library which is bundled with Joomla! 1.5
Now the output looks like this
Which brings us to the second problem,The TCPDF Library only outputs text from Left-To-Right which causes RTL scripts to be displayed in reversed order, simply reversing the string before passing it to the rendering engine won’t fix this problem, I think FriBidi may fix this but it is not available with every php Installation so I can’t relay on it to fix this problem for Joomla! ,So I gave it a shot and written my own code (I always like to write my own code ;P), The code I wrote simply breaks down text into pieces based on its UTF-8 range and then reverses the pieces “runs” that are identified as RTL “like Arabic” and leaves other runs without modification.
Letters are correctly shaped “with minor errors” and are rendered right to left, however, the lines are reversed , you should be able to read it correctly by starting from the bottom line and proceed upwards,I’m yet to fix this problem , If you have any suggestions on how to fix this or an easier way of doing the whole thing please let me know, I think there gotta be a better way of doing this.
Edit ( 8/5/2007 ) : I have managed to fix that issue but the code still needs to much clean-up and bug-proofing , here’s a sample of the output.




I’m am from morocco .I want to develop a web sit in arabic using Joomla
if there is a version in Arbic or any help please tell me as soon as possible
I am using the TCPDF for pdf creation.As you said it does not prints the arabic characters right to left and charcters are not joined as required.I have tried ArGlyphs class to fix this problem but still no luck.Could you elaborate how do you used this class to tackle this issue?.Thanks in advance
“The code I wrote simply breaks down text into pieces based on its UTF-8 range and then reverses the pieces “runs” that are identified as RTL “like Arabic” and leaves other runs without modification.”
Could you please post the code for the modifications?
بس لو تسمحلنا نستخدمه بشكله الحالي ونحاول نعدل فيه ونطوره،
Please tell me how to Download the modified files.
ويخدم ملايين البشر ، منهم من يعرف عنه ومنهم من يستفيد منه دون ان يعرف عنه
فبالنيابة عن هؤلاء الملايين من البشر الذين يتحدثون ويقرأون العربية ونيابة عن تريلونات الكلمات والصفحات
شكرا لك بعددهم … شكرا شكرا
عبدالرحمن - الرياض
Thanks
but i can`t download it
do you can take better link?
this is just svn version.
Thanks
إني أحاول المساعدة في تحسين خاصية بي دي إف في جملة 1.5 و الحمد للله لقد وجدت بعض الحلول خاصة لإضهار صورة
GIF
التي لا يدعمها تي سي بي دي إف و هذا بعد تعديل الكود الخاص ب البي آش بي 5
هنا
و قمت بتعديلع ليتناسب و البي آش بي 4 حيث أن جملة 1.5 يستعمل نسخة البي آش بي 4
الحل موجود هنا
http://forum.joomla.org/index.php/topic,228896.msg1130678.html#msg1130678
و بقيت إضهار اللغة العربية في البي دي إف
Thanks.
أرجو حد يفهمني الحل ! ! !