Reversing Strings in Right To Left (BiDirectional) Languages in iTextSharp

bidi, c#, itext

Solution

To show RTL texts by using iTextSharp correctly:

- You need to set the font's encoding to `BaseFont.IDENTITY_H`

- Then you have to use container elements which support `RunDirection`, such as `PdfPCell`, `ColumnText`, etc. and now you can set their `element.RunDirection = PdfWriter.RUN_DIRECTION_RTL`;

Problem

I'm using iTextSharp( C# iText port) to create pdfs from text/html. Most of my text is in Hebrew, a Right-To-Left language. My problem is that PDFs show RTL langauge in reverse, so I need to reverse my strings in a way that would only reverse the RTL text without reversing any numbers or text in English. It is my understanding that fribidi allows doing that on linux, but I couldn't find any solutions for this problem for Windows. I would welcome any suggestions, including an alternative to iTextSharp that would do this automatically (if one exists).

Original source