问题
I have the below situation and issue I would like to ask your input and help. At the company we have an app that generates PDF and we are using iTextSharp for that purpose. And so far we used only Latin alphabet, but now we have to upgrade the app to use Arabic alphabet too. The generator gets the input in json file and it already contains the proper Arabic texts in the proper format (I mean in right to left format) The ColumnText component (from iTextSharp) gets everything that is needed to "draw" the desired part into PDF template, the only problem that somewhy the given text is reserved. (So it converts the correct RTL format to LTR). With Latin texts it works correctly, doesn't convert at all. I tried to set the RunDirection property, but none of the options gave the desired result.
These converted the text to RTL, however missed some letters from the original text (I don't know why)
RUN_DIRECTION_RTL
RUN_DIRECTION_LTR
RUN_DIRECTION_DEFAULT
Example: What I want: ليس هذا تصريح صعود للطائرة
What I got: ليس هذ تصريح صعو للطائر (Bold letters are missing)
If I used that one (RUN_DIRECTION_NO_BIDI) than all letters are ok, but unfortunately the text is LTR.
I reversed the text just before passing to iTextSharp and after it re-reversed so finally it was ok on the PDF, but we have such arabic texts that have Latin words inside them in the middle and in that case manually reverse doesn't help, because iTextSharp converts only the arabic texts. So "string-manipulations" led to chaos.
How can I make that iTextSharp to not modify the given arabic texts at all, just render it into PDF template as it was given? I've read that this package is obsolete, so it is officially encouraged to upgrade the newest iText 7. Would it solve my problem?
Thanks for the answers.
来源:https://stackoverflow.com/questions/61959671/arabic-text-with-itextsharp-rtl