Anybody know how to write arabic text using dynapdf on linux system. Its working perfectly on wondows OS. but gives garbage result on linux system using the exact source code.
Do you have the same fonts (ttf probably) used on Windows installed in the Linux machine?
I believe the usual ones are Trado.ttf and Tradbdo.ttf on Windows
I am using the font Arial and i installed it on Linux as well.
I guess you could write a sample text that breaks here, and show a clipped picture of the same text as it shows in the messed PDF so we have an idea of what’s going on. Later, or in parallel, if the community can’t find something “obvious”, Christian will have something to work on.
Arabic Name : شركة الكويت والشرق الاوسط للاستثمار المالي -الكتروني1
From Windows OS. This is ok
From Linux OS. The Arabic looks garbage and showing in reverse order
That looks like a Unicode BIDI algorithm problem. Have you checked the source string you pass to DynaPDF to see if the bytes are the same on Windows and Linux?
Yes i do and the source are same. I just compiled it for windows and linux. pdf looks good on windows and garbage on linux. I think dynaPDF dosent support Unicode BIDI algorithm on linux OS. Have contacted @Christian_Schmitz and lets see if he can come up with a solution.
Are you loading the font into DynaPDF with the Unicode code page as I think that is required for BIDI to work.
Yes and either you use ComplexText flag (Windows only) or the BIDI Mode.
See SetBidiMode method.
I am using the setbidimode and unicode codepage. The issue is only on linux and windows is ok
Here is the text sample for those testing the case with DynaPDF ( cc. @Christian_Schmitz ):
Based on this:
Looks like some platform isolated (Linux) bug
From the DynaPDF manual…
Complex Text Layout
Support for complex text layout is required for languages like Arabic, Thai, Devanagari, Lao, and many others. At time of publication DynaPDF supports complex text layout on Windows only.
The implementation in DynaPDF based on Microsofts Uniscribe. This is the Unicode library that is used behind the scenes in almost all Windows controls and Unicode aware applications.
Complex text layout depends on the availability of OpenType fonts. Most fonts which are delivered with Windows are OpenType fonts.
It looks like you may be trying to use a feature that isn’t supported on Linux or macOS.
Agreed. But the plugin claims to be cross-platform.
Well, DynaPDF should be able to print Arabic Unicode characters in BidiMode.
But it doesn’t do the conversion of characters for their position in words or ligatures.
The Example projects “Create PDF with Arabic” do that themselves a bit.
But on Windows you use Microsoft’s library and that one doesn’t come with Linux.
I think Jens would have to integrate the Harfbuzz layout engine into DynaPDF to make the feature cross platform.
Well using your example mentioned i tried to print from linux. Now the arabic text is proper but in a table cell the text is printing like from bottom to up. See the screenshot below the second line should come first and there was an english number at the end of the text and it got missing at the time of conversion by calling the Convert method.
From Linux OS - Its showing bottom to up and the character ‘1’ is missing after conversion
From Windows OS - This is ok
So the order of lines is wrong?
Do you have a little test project for this?
I’d have to reproduce this in C++ to show to Jens as a bug.
I have send you the source file showing the issue in Linux. Hope you with Jens can find a solution.
We got an answer and unfortunately DynaPDF can’t wrap Arabic text. Sorry.
That’s very unfortunate to hear. I am stuck with Windows only solution. I will try with Xojo built-in pdf class now.