In Itext 5.x, we should reshape characters. In other words, we should handle the formats of each Arabic( or Persian) character.
For example, for ب we have 4 formats:
ب isolated
با initial ( start with ب)
آب final (end with ب)
عباس middle (appears in the middle of a word)
I have tested in Java with icu4j( 74.1)
Note: icu4j just supports reshaping Arabic characters. For Persian characters like گچ پژ you should handle them manually.