RTL not working in pdf generation with itext 5.5 for Arabic text

前端 未结 3 758
北恋
北恋 2020-12-04 03:14

I have java code that writes arabic characters with the help of itext 5.5 and xmlworker jars, but its writing left to right even after writer.setRunDirection(PdfWrit

3条回答
  •  -上瘾入骨i
    2020-12-04 03:19

    As documented, this is not supposed to work:

    writer.setRunDirection(PdfWriter.RUN_DIRECTION_RTL);
    

    Arabic (and Hebrew) can only be rendered correctly in the context of ColumnText and PdfPCell. In other words: if you want to use Arabic from XML Worker, you need to create an ElementList and then add the elments to a ColumnText object as is done here.

    You need to set the run direction at the level of the ColumnText object.

提交回复
热议问题